parser: reject builtin-named binding LHS with ILO-P011#294
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
3547b6b to
8d7342d
Compare
A local binding like `flat=cat ls " "` was silently accepted, then any later use of `flat` in operand position resolved to the 1-arg flatten builtin (the verifier checks is_builtin before locals), surfacing as a misleading `ILO-T006 'flat' expects 1 args, got 0`. The agent has no signal that the local binding is being shadowed. Mirrors the PR #245 precedent for builtin-named user functions: intercept at parse time with ILO-P011 and a rename hint (`myflat`, `flatv`) in both parse_decl (top-level) and parse_stmt (in-function) binding sites. Existing `fld=` per-name block keeps its specific fold-builtin message since it runs before the generic check. Cross-engine regression test covers twelve builtin names across tree, VM, and Cranelift, plus the exact pdf-analyst rerun3 repro and a sanity check that the renamed binding compiles and runs. examples/builtin-binding-name-rename.ilo demonstrates the correct shape (`body=cat ls " "`) for the `spl body ". "` pipeline.
Extends the Reserved words section in SPEC.md (auto-regenerates ai.txt via build.rs) and the syntax-rules section in skills/ilo/SKILL.md to mention the new parse-time rejection of builtin-named bindings. Lists the same names the parser checks (flat, frq, map, flt, cat, len, srt, hd, tl, ord, fld, lst) and shows both the function-name and binding-LHS error shapes so agents see the rename hint shape before they hit it.
8d7342d to
d8acf9e
Compare
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
Pattern-matches PR #245's parse-time rejection of builtin-named user functions, extending it to local-binding LHS. A binding like
flat=cat ls " "was silently accepted by the parser; any later use offlatin operand position resolved to the 1-arg flatten builtin (the verifier checksis_builtinbefore locals), and the agent saw the misleadingILO-T006 'flat' expects 1 args, got 0instead of a signal that the local binding was being shadowed.Persona origin: 2026-05-16 pdf-analyst re-run against v0.11.2, friction #6.
Manifesto framing: silent mis-dispatch is the worst class of bug for an AI agent because there is no diagnostic to retry against. The parser now intercepts at the binding site with
ILO-P011 \flat` is a builtin and cannot be used as a binding nameplus a rename hint (myflat,flatv`). First retry is the right one.Repro
Before:
After:
What's in the diff
f98748e parser: reject builtin-named binding LHS with ILO-P011 — adds
Builtin::is_builtin(name)guards to bothparse_decl(top-level) andparse_stmt(in-function) binding sites, runs after the existing per-namefld=block so the fold-specific hint still wins. Twelve-builtin cross-engine regression test (tree, VM, Cranelift) covering both top-level and in-function binding forms, the exact pdf-analyst rerun3 repro, and a sanity check that the renamed binding compiles and runs.examples/builtin-binding-name-rename.ilodemonstrates the correct shape.3547b6b docs: note builtin names rejected as binding LHS — extends the Reserved words section in
SPEC.md(auto-regeneratesai.txtvia build.rs) and the syntax-rules section inskills/ilo/SKILL.mdto mention the new rejection, listing the same names the parser checks and both the function-name and binding-LHS error shapes.Test plan
cargo test --release --features craneliftpasses the full suite (127 test crates, 0 failures) in the isolated worktree target dirregression_builtin_binding_name(15 tests) passes on tree, VM, and Craneliftregression_friendly_errors::friendly_fld_bindingstill passes (per-namefldblock preserved)regression_builtin_fn_name(PR reject builtin-named user functions at parse time #245 parent) still passesexamples_engines.rsexercises the newbuiltin-binding-name-rename.iloacross every engine and confirmslen parts == 3git diff ai.txtmatches the SPEC.md-driven regeneration (build.rs CI check passes)Follow-ups
{flat;y}=...) and@flat xs{...}foreach variables are out of scope. They share the same operand-position dispatch risk but are much rarer in practice and would each need a separate intercept point. Filing as parked.