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
A zero-argument recursive type definition checks, but --verdict and -o stack-overflow elaborating it #1164
BEND_NO_TELEMETRY=1 bend omega2.bend --check-only (passes), then BEND_NO_TELEMETRY=1 bend omega2.bend --verdict
What happened
--check-only prints ALL PROOFS CHECK, but --verdict (and -o x.bendtt too, so it is the elaborator, not the kernel binary) exits 1 with:
Error: the machine stack overflowed (a deep recursion, or a literal too large to expand)
No .bendtt file is written. A type definition whose body names itself with no argument (F below) is accepted by bend2, and elaborating om's domain seems to unfold F forever.
Reproduced on main (2.0.34). The overflow is in safe.ts's η-long elaboration, not in om's domain. F goes out as a plain reference, and def om(f: @-x: F -> Empty) -> Unit: Unit{} elaborates fine.
safe.ts writes every term of a function type η-long, because bend2 converts up to η and the kernel doesn't. For f(f), arg_term (safe.ts:1128) η-expands the argument f at type F to λ-x => f(x), with x : F. Elaborating that body applies f to x, which is another argument of type F, so it η-expands again, and this never stops. tree's rule for leaves of a function type loops the same way: def om(f: @-x: F -> Empty) -> @-x: F -> Empty: f also overflows.
This isn't specific to self-application. Any type def that unfolds to a function over itself has an infinite η-long form. A positive, continuation-style one checks in bend2 and overflows the elaborator in the same place:
Recursion through the codomain has the same infinite η-long form, and there bend2's own checker already hangs, before safe.ts runs. Declaring the type checks instantly, but passing a value of it through a def keeps --check-only running indefinitely (killed after 15 s, and after 4 min on a first try):
importBasedefSink() ->Type:
U32->Sinkdefkeep(s: Sink) ->Sink:
s
A likely fix for safe.ts: stop η-expanding at a recursive type def that is already being expanded on the current path, and leave the term as it is. The kernel type-checks non-η-long terms without trouble; η-long form only matters for equations bend2 closed by η. Written by hand into the .bendtt, both om : ∀x0 : ∀-x1 : F -> Empty -> Empty = λx0 => (x0 -λ-x1 => (x0 -x1)) and λx0 => (x0 -x0) print ALL PROOFS CHECK.
Activity
nicolas-abril commentedon Sep 29, 2026
Reproduced on
main(2.0.34). The overflow is insafe.ts's η-long elaboration, not inom's domain.Fgoes out as a plain reference, anddef om(f: @-x: F -> Empty) -> Unit: Unit{}elaborates fine.safe.tswrites every term of a function type η-long, because bend2 converts up to η and the kernel doesn't. Forf(f),arg_term(safe.ts:1128) η-expands the argumentfat typeFtoλ-x => f(x), withx : F. Elaborating that body appliesftox, which is another argument of typeF, so it η-expands again, and this never stops.tree's rule for leaves of a function type loops the same way:def om(f: @-x: F -> Empty) -> @-x: F -> Empty: falso overflows.This isn't specific to self-application. Any type def that unfolds to a function over itself has an infinite η-long form. A positive, continuation-style one checks in bend2 and overflows the elaborator in the same place:
Recursion through the codomain has the same infinite η-long form, and there bend2's own checker already hangs, before
safe.tsruns. Declaring the type checks instantly, but passing a value of it through a def keeps--check-onlyrunning indefinitely (killed after 15 s, and after 4 min on a first try):A likely fix for
safe.ts: stop η-expanding at a recursive type def that is already being expanded on the current path, and leave the term as it is. The kernel type-checks non-η-long terms without trouble; η-long form only matters for equations bend2 closed by η. Written by hand into the.bendtt, bothom : ∀x0 : ∀-x1 : F -> Empty -> Empty = λx0 => (x0 -λ-x1 => (x0 -x1))andλx0 => (x0 -x0)printALL PROOFS CHECK.safe.ts: a term at a type with no finite η-long form goes out whole (b…
safe.ts: a term at a type with no finite η-long form goes out whole (b…
safe.ts: a term at a type with no finite η-long form goes out whole (b…
safe.ts: a term at a type with no finite η-long form goes out whole (b…
safe.ts: a term at a type with no finite η-long form goes out whole (b…
safe.ts: a term at a type with no finite η-long form goes out whole (b…
safe.ts: a term at a type with no finite η-long form goes out whole (b…
safe.ts: a term at a type with no finite η-long form goes out whole (#…