recognize zero-arg name() and name!() in every operand position#239
Merged
Conversation
SPEC.md:16 documents `make-id()` and SPEC.md:843 documents `fetch!()`,
but `parse_atom`'s Ident arm returned `Expr::Ref` immediately without
inspecting the trailing parens. The lookahead block already existed in
`parse_call_or_atom` (line 1803-1814), so `cx=xs()` worked, but every
operand-position use went through `parse_operand` -> `parse_atom` and
failed with `ILO-P009` / `ILO-P003`:
- `len xs()`, `hd xs()`, `at xs() 0` (zero-arg call as builtin arg)
- `map dbl xs()` (HOF collection slot)
- `@v xs(){...}` (loop subject)
Mirror the same two-token lookahead inside `parse_atom`, for both the
bare `name()` form and the auto-unwrap `name!()` form. Bare `name`
(without parens) still parses as `Expr::Ref` so HOF fn-refs like
`fld max xs 0` are unaffected.
Five parser unit tests cover the four formerly-broken positions and one
guard against regressing the HOF fn-ref path:
- `zero_arg_call_as_builtin_arg` (`len xs()`)
- `zero_arg_call_as_hof_collection_arg` (`map dbl xs()`)
- `zero_arg_call_as_loop_subject` (`@v xs(){...}`)
- `zero_arg_unwrap_call_in_operand_position` (`len fetch!()`)
- `bare_ident_still_parses_as_ref_for_hof_arg`
`examples/zero-arg-call.ilo` exercises the same five scenarios across
the tree, VM, and Cranelift engines via the `tests/examples_engines.rs`
harness, giving cross-engine regression coverage without touching any
backend code.
Codecov Report❌ Patch coverage is
📢 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
Closes the routing-tsp persona friction at
ilo_assessment_feedback.md:1564. SPEC.md:16 says zero-arg call ismake-id()and SPEC.md:843 documentsfetch!(), but the implementation only recognised the parens at statement head / RHS of=. Every operand-position use (call arg, HOF collection slot, loop subject, range bound) routed throughparse_operand→parse_atom, where the Ident arm returnedExpr::Refimmediately and then choked on the dangling(.Two-token lookahead inside
parse_atom's Ident arm, mirroring the existing block atparse_call_or_atom:1803-1814. Barenamestill parses asExpr::Ref, so HOFs likefld max xs 0are unchanged — only the explicit()triggers invocation. What you read is what runs.Repro
Before this PR, on
4ef85d4:Same failure for
hd xs(),at xs() 0,map dbl xs(),@v xs(){...}. After this PR all five positions parse and produce the same values across--run-tree,--run-vm, and--run-cranelift.What's in the diff
name()andname!()zero-arg calls in operand position — the parser fix. ~30 lines inparse_atom, mirrors the existing statement-head lookahead. Both the barename()form and the auto-unwrapname!()form are handled.examples/zero-arg-call.iloexercising the same scenarios across all three engines via the existingtests/examples_engines.rsharness.Test plan
cargo test --release --features craneliftgreen (parser + verifier + tree + VM + cranelift JIT/AOT + examples harness)zero_arg_*parser unit tests passexamples/zero-arg-call.iloruns identically across--run-tree,--run-vm,--run-craneliftmap dbl xs(no parens) still parses asRefso HOFs are unaffectedFollow-ups
@v map dbl xs()(HOF call in loop-subject position) is still rejected —parse_operanddoesn't call-parse there. Separate pre-existing limitation. Workaround in the example: bind to a name first (ys=map dbl xs();@v ys{...}).