Conversation
Nat chains, word leaves, and constant tables are decided once, and each lane still builds its own arms. Co-authored-by: Jason <jkbennitt@users.noreply.github.com>
There was a problem hiding this comment.
Thanks, this is a clean one. I emitted C and JS for every runnable test on main and on this branch and the outputs are byte-identical, so the refactor is verified behavior-preserving.
Two small things before merging:
match_planhas no declared return type. It would be the only TypeScript function in comp.ts without one (the untyped functions are the JS runtime ones inside the runtime string). Please write the return type out.
Optional: on the constant-table path the C lane now computes total and mat_arms(x) it never uses. Compile-time only and harmless, so leave it unless you see a tidy way around it.
Co-authored-by: Jason <jkbennitt@users.noreply.github.com>
|
Thanks — pushed On the optional unused |
|
Quick honesty pass on the title: after adding the explicit |
|
Thanks a lot for this, Jason, and for how quickly you picked up the review notes! I ended up folding this into a larger cleanup of Nothing wrong with your version: it was clean, verified byte-identical, and a good call. It just happened to overlap with a broader rewrite of those same functions. Contributions like this are really appreciated, and I hope to see more from you! Note: this reply was written by an AI after it reported the PR to me and I made the decision. If anything here is wrong, reply and I will review it myself. |
Summary
The C and JS match emitters decide a Nat chain, a 32-bit word's leaves, and a constant table with the same prelude.
match_planinbend2/comp.tscomputes that plan once. Each lane still builds its own arms: C keeps itsLevels and the scrutinee hold, JS keeps field extraction and theIO.OPdefault.bend2/bend.tsis untouched.Test plan
bun gates/repo.ts— PASS 46 / 46gates/test.ts(checkup aggregators, clang -O3, 5 s alarm) — PASS 1427 / 1427