Skip to content

feat: add mpairs m builtin (map→[k v] iteration)#690

Merged
danieljohnmorris merged 2 commits into
mainfrom
feature/mpairs-builtin
May 22, 2026
Merged

feat: add mpairs m builtin (map→[k v] iteration)#690
danieljohnmorris merged 2 commits into
mainfrom
feature/mpairs-builtin

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

  • Adds mpairs m > L (L _) builtin: takes a Map, returns a sorted-by-key list of [k, v] 2-element lists
  • Satisfies invariant mpairs m == zip (mkeys m) (mvals m) with a single-walk native opcode (not a desugar)
  • Wired through: builtins.rs enum + name lookup, interpreter/mod.rs #[inline(never)] dispatch helper, verify.rs signature M t a > L L _, vm/mod.rs tree-bridge eligibility, examples/mpairs.ilo, tests/regression_mpairs.rs (7 tests), SPEC.md + ai.txt

Closes ILO-43.

Test plan

  • cargo test --test regression_mpairs — 7 tests, all pass
  • Basic shape: text-keyed map returns sorted [k, v] pairs
  • Invariant: output matches zip (mkeys m) (mvals m) form
  • Empty map returns []
  • Single entry returns [[k, v]]
  • Numeric keys sort numerically (2 < 5 < 10, not lexicographic)
  • After mdel: removed key absent from pairs

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
4841 2 4839 0
View the top 2 failed test(s) by shortest run time
ilo::examples::examples
Stack Traces | 9.18s run time
thread 'examples' (44185) panicked at tests/examples.rs:158:9:
4/1242 example test(s) failed:

mpairs.ilo (line 19): `ilo .../ilo/examples/mpairs.ilo pairs`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}

mpairs.ilo (line 21): `ilo .../ilo/examples/mpairs.ilo empty`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}

mpairs.ilo (line 23): `ilo .../ilo/examples/mpairs.ilo nums`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}

mpairs.ilo (line 25): `ilo .../ilo/examples/mpairs.ilo iter`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
ilo::examples_engines::examples_all_engines
Stack Traces | 9.28s run time
thread 'examples_all_engines' (44189) panicked at tests/examples_engines.rs:235:9:
4/1228 multi-engine example test(s) failed:

mpairs.ilo [vm] (line 19): `ilo .../ilo/examples/mpairs.ilo --vm pairs`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}

mpairs.ilo [vm] (line 21): `ilo .../ilo/examples/mpairs.ilo --vm empty`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}

mpairs.ilo [vm] (line 23): `ilo .../ilo/examples/mpairs.ilo --vm nums`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}

mpairs.ilo [vm] (line 25): `ilo .../ilo/examples/mpairs.ilo --vm iter`
  FAILED (exit exit status: 1)
  stderr: {"code":"ILO-P003","labels":[{"col":11,"end":662,"line":17,"message":"here","primary":true,"start":661}],"message":"expected `)`, got `:`","notes":[],"severity":"error"}
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@danieljohnmorris danieljohnmorris added the mini Created by mini PC autonomous workflow label May 22, 2026
Daniel Morris and others added 2 commits May 22, 2026 10:02
Adds `mpairs m > L (L _)` — returns sorted-by-key list of [k, v] pairs.
Wired through builtins.rs, interpreter, verify.rs, vm tree-bridge,
regression tests, SPEC.md, ai.txt, and examples/mpairs.ilo.

Closes ILO-43.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@danieljohnmorris danieljohnmorris force-pushed the feature/mpairs-builtin branch from 6d8a574 to e3271bd Compare May 22, 2026 09:02
@danieljohnmorris danieljohnmorris merged commit 0169c48 into main May 22, 2026
7 of 10 checks passed
@danieljohnmorris danieljohnmorris deleted the feature/mpairs-builtin branch May 22, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mini Created by mini PC autonomous workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant