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 nat-literal pattern skips the constructor arity check, so a non-decreasing self-call passes and a closed term inhabits Empty #852
type U is Data:
Un{}
type N is Data:
Zero{w: U}
Succ{p: N}
type D is Data:
K{z: N}
type Empty is Data:
def f(b: N) -> Empty:
match b:
case U32.to_nat(0):
{\{K: q => w => f(q)} : D -> U -> Empty}(K{Zero{Un{}}})
case Succ{p}:
f(p)
def boom() -> Empty:
f(Zero{Un{}})
Any literal above 256 takes the same path.U32.to_nat(0) is the longhand, but plain literals reach it too, because nat_to_term expands a literal up to NAT_LITERAL_MAX = 256 into a Succ chain and anything larger into U32.to_nat(n). On the type from the report:
case 255n -> "a Zero pattern with 1 field" caught
case 256n -> "a Zero pattern with 1 field" caught
case 257n -> accepted, branch goal becomes @w:U -> U
case 300n -> accepted, branch goal becomes @w:U -> U
So the checker's verdict on a pattern changes at 256, and an ordinary literal is enough to hit it.
The two pattern paths differ in parse_patt (bend.ts:1727). The literal branch builds the pattern and returns before reaching the constructor case:
It never calls book_ctr, so neither the unknown-constructor check nor the arity check at :1744-1750 runs. Written honestly both checks fire: case Zero{}: gives "a Zero pattern with 1 field", and the self-call gives "expected: a decreasing self-call". Only the literal spelling escapes both.
Related: bend.ts:2763 does its own arity check with a different message, so there is more than one place building patterns without the shared check.
Fixed in 2.0.17. A literal pattern is now built as a constructor term and falls through to the same check every other pattern takes, so its arity is verified; the second arity check that used to sit in match_flatten was unreachable after that and is gone. Your file is refused with a Zero pattern with 1 field.
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
PedroVIOliv commentedon Sep 19, 2026
Two things that may help narrow it.
Any literal above 256 takes the same path.
U32.to_nat(0)is the longhand, but plain literals reach it too, becausenat_to_termexpands a literal up toNAT_LITERAL_MAX = 256into aSuccchain and anything larger intoU32.to_nat(n). On the type from the report:So the checker's verdict on a pattern changes at 256, and an ordinary literal is enough to hit it.
The two pattern paths differ in
parse_patt(bend.ts:1727). The literal branch builds the pattern and returns before reaching the constructor case:It never calls
book_ctr, so neither the unknown-constructor check nor the arity check at :1744-1750 runs. Written honestly both checks fire:case Zero{}:gives "a Zero pattern with 1 field", and the self-call gives "expected: a decreasing self-call". Only the literal spelling escapes both.Related: bend.ts:2763 does its own arity check with a different message, so there is more than one place building patterns without the shared check.
nicolas-abril commentedon Sep 19, 2026
Probably due to fb36663
A literal pattern is checked like its constructor; a def that fills n…
VictorTaelin commentedon Sep 19, 2026
Fixed in 2.0.17. A literal pattern is now built as a constructor term and falls through to the same check every other pattern takes, so its arity is verified; the second arity check that used to sit in
match_flattenwas unreachable after that and is gone. Your file is refused witha Zero pattern with 1 field.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.
Merge canon/main (Bend 2.0.25+2) into the omen line
A literal pattern is checked like its constructor; a def that fills n…