fix: multi-line bodies inside brackets, parens, and >> pipe chains#246
Merged
Conversation
normalize_newlines was unaware of paren/bracket depth, so an indented continuation inside a list literal or paren-group got a `;` injected between tokens (`xs=[\n 1,\n 2]` became `xs=[;1,;2]`, ILO-P009 at a bewildering column). Now `(` `[` open a depth counter and newlines inside become a single space; `)` `]` close it. Continuation lines starting with `>>` (pipe operator) suppress the `;` too. `>>` is the only operator that's never a valid statement start in ilo's prefix-call grammar, so this is unambiguous. `+`/`-`/`*` etc. remain untouched so `+x 1` stays a valid statement head. String literals are walked through verbatim (already true post #236) so brackets and pipe tokens inside text don't affect depth.
Extends regression_multiline_fn_body across tree/vm/cranelift with the
shapes the personas kept hitting: multi-line `[...]` list literal,
leading-comma list, multi-line `(...)` paren-group, multi-line `>>`
pipe chain, nested `(` inside `[`, and pipe chain inside a `{...}`
loop body.
Also adds examples/multiline-bodies.ilo so the same shapes get exercised
by the examples_engines harness and an agent reading examples sees the
indented form as canonical.
run_file now whitespace-splits `entry` so cases like `gp 5` pass the
argument as its own argv slot, matching how examples_engines invokes
the CLI.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three persona-flagged shapes (
Multi-line function bodies still fatal, L1310 quant-trader, L1325 re-flag, L938 db-analyst, plus the cross-persona summary at L1023) all came from one root cause:normalize_newlinesinjected a;between tokens that weren't statement boundaries. Post-#168 the header→body case was fixed; this PR finishes the job for the remaining three shapes.The token-cost framing: every persona who reached for natural indented body shapes paid a 5-minute debug-and-collapse tax, plus the
ILO-P009 expected expression, got Semiat a column deep inside a continuation line obscured the real cause. Manifesto cost was real and repeated.Repro before/after
Pre-fix, all three failed with
ILO-P009:Post-fix, all three run on tree, vm, and cranelift.
What's in the diff
( )and[ ]and after>>.normalize_newlinestracks(/[depth and treats newlines inside as a single space (so(+x\n 1)doesn't normalise to(+x1)). Continuation lines that start with>>(the only operator that's never a valid statement start) suppress the;too;+/-/*etc. are valid prefix-call heads and stay untouched. String walking is pre-existing from fix: comments above bound-call lines no longer corrupt parsing #236; this PR just relies on it so brackets inside text don't bump depth.regression_multiline_fn_body.rs(multi-line list, leading-comma list, multi-line paren, multi-line pipe, nested(inside[, pipe chain inside a{...}loop body) across tree/vm/cranelift. Newexamples/multiline-bodies.iloso the example_engines harness exercises the same shapes and an agent reading examples sees indented bodies as canonical.Test plan
cargo test --release --features cranelift --test regression_multiline_fn_body— 3 tests across tree/vm/cranelift, all greencargo test --release --features cranelift --test examples_engines— examples harness green including new filecargo test --release --features craneliftfull suite — 2871 lib passed, 0 failed; all integration tests greencargo fmt --checkcargo clippy --release --features cranelift --all-targetsOut of scope
Pattern 4 from the investigation (indented
--comments above paren-bound calls) was already in flight onfix/comment-parse-corruptand shipped in #236 before this PR landed. The two changes coexist; this PR rebased onto the merged #236.Follow-ups
;no longer lands inside a continuation) but a full span-rewrite is a separate piece of work.