A bare literal in a template is not a dropped statement - #383
Conversation
`<% unless cond %>…<% end %>` reaches the view walker as `if cond then nil else … end`. The `then` arm is a synthesized `nil` with no span; it fell to the catch-all, which filed a span-less "template statement dropped (unknown stmt)" for every `unless` in a template. A literal in statement position renders nothing and runs nothing, so nothing is lost: it now lowers to the same empty append without a ledger line. The catch-all keeps reporting real drops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughBare literal statements now lower to no-op appends instead of unknown-statement TODO appends. Regression tests check that ChangesLiteral statement lowering
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change addresses false residue reports for bare literals while retaining diagnostics for unsupported statements. No material merge-blocking risk is evident. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Probed on
main(26365fa).The view walker's catch-all files a
lower_residueline ("template statement dropped (unknown stmt)") so dropped template statements are visible. Every<% unless %>trips it with a false positive, and without a location:unlessreaches the walker asif cond then nil else … end. Thethenarm is a synthesizednilliteral (synthetic span), so the catch-all reports it as a dropped statement with no file or line. The rendered output is already correct; only the ledger is wrong. In a real app (a Rails time tracker) these were the only "template statement dropped" lines left, and with no span there was nothing to follow.A literal in statement position renders nothing and runs no side effect, so there is nothing to drop. It now lowers to the same
io << ""without a ledger line (noop_io_append, split out oftodo_io_append). Genuine drops still report, pinned by the existingan_unlowerable_statement_files_residue.Tests (
tests/view_walker_residue.rs):an_unless_block_files_no_residue_and_keeps_its_bodyanda_literal_statement_files_no_residue; both fail onmain.Ran:
view_walker_residue(5),emit_and_run(107),lowered_ruby_emit(108),real_blog(6).Summary by CodeRabbit
unlessblock bodies no longer produce unexpected residue in generated output.