Skip to content

parser: ?h ternary operand slots expand known-arity calls#380

Merged
danieljohnmorris merged 6 commits into
mainfrom
fix/ternary-call-operand
May 18, 2026
Merged

parser: ?h ternary operand slots expand known-arity calls#380
danieljohnmorris merged 6 commits into
mainfrom
fix/ternary-call-operand

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Closes security-researcher + scientific-researcher rerun9. ?h/?=/?> then/else slots now accept known-arity calls inline, no bind-first required.

Mirror the prefix-binop operand fix from #332 to the then/else slots of
the prefix-ternary family (`?=cond a b`, `?>cond a b`, ...) and the
`?h cond a b` general keyword form. `parse_operand` (atom-only) is
swapped for `parse_prefix_binop_operand`, so a known-arity ident
followed by enough trailing operands expands into a nested Call rather
than being left as a bare Ref.

Before: `?h =a b sev sc "NONE"` parsed `sev` as a bare Ref and
then choked on `sc "NONE"`. Workaround was to bind-first or to
wrap in parens (the paren form already worked via parse_atom's LParen
branch). After: the no-parens shape parses naturally.

Same shadow-safe guard as the prefix-binop site - locals that shadow a
user fn name still resolve via Ref because parse_prefix_binop_operand
only expands when the next token can start another operand.
Pins the behaviour across tree/VM/Cranelift for every operand-slot
shape that the parser fix unblocks:

- `?h cond a b` then-slot and else-slot known-arity calls
- both branches as calls in the same `?h` form
- `?=cond a b` family with a call in the then-slot
- `?>cond a b` with a call in the else-slot
- parenthesised `(sev sc)` remains a valid alternative
- PR #330's 2-operand bool-subject `?h dbl x 0` still parses
- local refs in operand slots still resolve as bare Refs

Also adds `examples/ternary-call-operand.ilo` with -- run / -- out
assertions so `tests/examples_engines.rs` exercises the example
file across every engine and so future agents see the now-correct
shape in their in-context learning examples.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@danieljohnmorris danieljohnmorris merged commit f7c759d into main May 18, 2026
4 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/ternary-call-operand branch May 18, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant