Skip to content

tests: cross-engine regression coverage for mget m k ?? d#228

Merged
danieljohnmorris merged 2 commits into
mainfrom
fix/mget-default
May 13, 2026
Merged

tests: cross-engine regression coverage for mget m k ?? d#228
danieljohnmorris merged 2 commits into
mainfrom
fix/mget-default

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

Persona reports going back several sessions (lines 699, 705, 926 of ilo_assessment_feedback.md) claim mget m k??0 parses as mget(m, k??0), forcing the two-step r=mget m k;v=r??0 tax on every map lookup with a default. On current main the bug is gone: the arity-aware call parser landed in 06477c5 registers mget with fixed arity 2, so ?? falls out as infix nil-coalesce on the whole (mget m k) result, and PR #169's ?? Optional-unwrap symmetry closes the loop on the value side.

No fix needed; what was missing was permanent coverage. This PR adds it.

Repro before / after

The supposedly-broken patterns all work today:

$ ilo 'f>n;m=mset mmap "k" 5;k="k";mget m k ?? 0' --run-tree f
5
$ ilo 'f>n;m=mmap;k="x";mget m k ?? 7' --run-cranelift f
7

AST confirms the grouping: NilCoalesce { value: Call(mget, [m, k]), default: ... }.

What's in the diff

Two commits, no src/ changes.

  1. examples: mget m k ?? d one-line lookup with defaultexamples/mget-default.ilo with 7 -- run: / -- out: assertions covering literal key, missing key, variable key, missing variable key, text-typed value, text default, and path-access key. Picked up automatically by tests/examples_engines.rs so every engine runs it on every CI build.

  2. tests: cross-engine regression for mget m k ?? dtests/regression_mget_default.rs with 9 cases per engine (tree, VM, Cranelift): literal hit/miss, variable hit/miss (the exact shape from persona line 699), text hit/miss, path-access key, call-result key, parenthesised key.

Adjacent finding (logged separately, not fixed here)

While writing this, I confirmed chained mget m "a" ?? mget m "b" ?? 99 does NOT parse — the right-hand side of ?? re-enters call-arg mode and slurps the next ?? as a third arg to the second mget. Single-mget defaults work; only chains break. Logged as a fresh entry in ilo_assessment_feedback.md; a dedicated PR can tackle it once we agree on the parser strategy.

Test plan

  • cargo test --release --features cranelift --test regression_mget_default — 3 passed (tree + VM + Cranelift)
  • cargo test --release --features cranelift --test examples_engines — all examples green
  • cargo test --release --features cranelift — full suite passes, no regressions
  • cargo fmt --all -- --check clean
  • cargo clippy --release --features cranelift --tests -- -D warnings clean

Follow-ups

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 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 edecb43 into main May 13, 2026
5 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/mget-default branch May 13, 2026 12:37
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