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
Checker recursion depth: valid programs with ~10k-deep terms (e.g. a 10000n literal) fail with "machine stack overflowed" #791
bend lit.bend (same via the bun/node import hook).
What happened
Error: the machine stack overflowed (a deep recursion, or a literal too large to expand)
5000n checks and runs fine; 10000n (and everything larger up to the advertised Number.MAX_SAFE_INTEGER bound) dies.
The same overflow hits valid non-literal programs: a single def body with ~4,000 sequential do-block statements fails the same way while the same program at 2,000 statements compiles (in 73s — see the separate quadratic-compile report).
So the practical term-depth budget of the checker is ~10k constructor nodes / call frames, well below any documented limit, and the MAX_SAFE_INTEGER guard in parse_term_num (bend.ts:2234) is decorative: nothing between ~10k and 9e15 can ever expand.
The failure itself is handled (caught RangeError with a decent message), so this is a robustness/usability issue, not a crash: valid programs fail with a message that doesn't say which literal or construct was too deep.
Expected
Make the checker's recursion depth budget explicit and iterative where cheap (the Nat literal expansion loop itself is iterative; the overflow happens downstream in checking/normalization).
At minimum, catch the overflow at the offending span and report "this literal/term is too large (limit ~N)".
Duplicate of #779 (same recursion: term_check <-> tele_check over the Succ chain of a Nat literal, same host-stack limit). The literal cap and the message are being decided there. Closing this one to keep the discussion in one place.
Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.
Activity
tests(deep): counts as products — checker literal-depth fix (5/5 dete…
integrate lane-regex R0-R2: # Regex section (parse/nullable/emit/comp…
VictorTaelin commentedon Sep 18, 2026
Duplicate of #779 (same recursion:
term_check<->tele_checkover the Succ chain of a Nat literal, same host-stack limit). The literal cap and the message are being decided there. Closing this one to keep the discussion in one place.Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.