You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The native lane skips an argument that bend file.bend and the JS lane evaluate, when the call's selector is a literal: one prints 100, the others stop with the Nat message #2181
bend drop.bend, bend drop.bend -o drop.js && node drop.js, and bend drop.bend -o drop && ./drop, built from main 8c329c1b.
What happened
The file checks (ALL PROOFS CHECK). bend file.bend and the JS lane stop the program; the native executable prints a result.
$ bend drop.bend
bend: a Nat past the largest immediate 2^48-1
$ bend drop.bend -o drop.js && node drop.js
bend: a Nat past the largest immediate 2^48-1
$ bend drop.bend -o drop && ./drop
100
pick(boom(k), 0n, 100n) never reads its first argument, and boom(k) goes past the Nat limit. The C lane never runs boom; the JS lane does.
It depends on the selector being a literal:
call
bend file.bend
JS
C
pick(boom(k), 0n, 100n)
stops
stops
100
pick(boom(k), Nat.sub(k, k), 100n) (a run-time zero)
stops
stops
stops
the same call, with pick rewritten to return z without a match
stops
stops
stops
x : Nat = boom(k) as an unused let, then print 100n
100
100
100
So the C lane skips the argument only where it can unfold pick at compile time. That is my reading of the table; I did not trace it in comp.ts.
I am not saying which answer is the right one, only that the lanes differ on a checked program. #775 was the same shape with a difference in cost only, and #1726 to #1729 went the other way (the native lane evaluated an overflowing call the result did not need).
I'm working on this: make emit_unfold refuse a fold when the chosen arm does not use a live, non-constant argument, so the call is emitted normally and evaluates that argument like the interpreter and JS lanes do. Plan: a regression test for pick(boom(k), 0n, 100n) plus a run-time-zero control. If someone is already on it, please say so and I'll stop.
I think the native lane is right here: pick(boom(k), 0n, 100n) is 100. The Nat wall is a runtime limit, not part of the semantics, and a lane may skip work the result doesn't need. Unused parameters are erased, and the checker assumes dead code isn't run, so it only guarantees that live code halts. That matches #1730 (the fix for #1726–#1729) and the unused-let row of the table above.
So #2199, which makes C evaluate the argument by refusing the unfold, goes the wrong way. If we want the lanes to agree, the interpreter and JS lanes should skip the argument instead. That's tied to the still-open strict-evaluation question from #775.
To be explicit about the scope here: the JS lane should agree with C and skip the argument (print 100). The interpreter should ideally agree too, but that's more complicated and may be out of scope for this issue.
Activity
YidaWeng commentedon Nov 17, 2026
I'm working on this: make
emit_unfoldrefuse a fold when the chosen arm does not use a live, non-constant argument, so the call is emitted normally and evaluates that argument like the interpreter and JS lanes do. Plan: a regression test forpick(boom(k), 0n, 100n)plus a run-time-zero control. If someone is already on it, please say so and I'll stop.fix(comp): a folded call evaluates an argument its chosen arm drops (b…
fix(comp): a folded call evaluates an argument its chosen arm drops (b…
nicolas-abril commentedon Nov 23, 2026
I think the native lane is right here:
pick(boom(k), 0n, 100n)is100. The Nat wall is a runtime limit, not part of the semantics, and a lane may skip work the result doesn't need. Unused parameters are erased, and the checker assumes dead code isn't run, so it only guarantees that live code halts. That matches #1730 (the fix for #1726–#1729) and the unused-letrow of the table above.So #2199, which makes C evaluate the argument by refusing the unfold, goes the wrong way. If we want the lanes to agree, the interpreter and JS lanes should skip the argument instead. That's tied to the still-open strict-evaluation question from #775.
nicolas-abril commentedon Nov 23, 2026
To be explicit about the scope here: the JS lane should agree with C and skip the argument (print
100). The interpreter should ideally agree too, but that's more complicated and may be out of scope for this issue.