Repository navigation
Description
What you did
For each of the three Base-free files below: bend F.bend, bend F.bend --check-only, bend F.bend -o out.bendtt (then bendtt out.bendtt), bend F.bend --verdict
What happened
crash.bend (no Unit anywhere; a def whose second ~ parameter is typed by its first)
$ bend crash.bend Mk{} exit 0
$ bend crash.bend --check-only ALL PROOFS CHECK exit 0
$ bend crash.bend -o out.bendtt TypeError: undefined is not an object (evaluating 'tld.c') exit 1
$ bend crash.bend --verdict TypeError: undefined is not an object (evaluating 'tld.c') exit 1
Adding def Unit() -> Type: In gives the same, with (evaluating 'tld.c.filter').
unit_param.bend (the book's own Unit takes one erased parameter)
$ bend unit_param.bend --check-only ALL PROOFS CHECK exit 0
$ bend unit_param.bend -o out.bendtt (prints nothing) exit 0
out.bendtt ends with: opaque idt_7e_A : *1 = Unit
$ bendtt out.bendtt SOME PROOFS FAIL exit 1
In idt_7e_A:
expected: *1
observed: ∀-x0 : *1 -> *2
$ bend unit_param.bend --verdict SOME PROOFS FAIL exit 1
Sorry - this is a mismatch between the TypeScript implementation, and the formalized BendTT kernel. ...
word.bend (a Base-free word type; bend2 takes the literal 7 at Box)
$ bend word.bend 7 exit 0
$ bend word.bend --check-only ALL PROOFS CHECK exit 0
$ bend word.bend -o out.bendtt BendTT: out of scope, so not in out.bendtt: exit 0
- main: names U32.lit7, out of scope: names U32, out of scope: an unknown name U32
$ bend word.bend --verdict SOME PROOFS FAIL / Sorry - this is a mismatch ... exit 1
With a def U32() -> Bit: True{} added (word_def.bend), -o exits 0 and emits
U32.lit7 : U32 = (.U32, ((.WCon, ...
typed at that def, and both kernels reject it: In U32.lit7: / expected: *1 / observed: Bit (exit 1).
With import Base (and no local Unit), crash.bend and unit_param.bend's idt/main pass --verdict.
The file
# ---- crash.bend ----
type In is Data:
Mk{}
def bad(~A: Type, ~z: A, x: In) -> In:
x
def main() -> In:
Mk{}
# ---- unit_param.bend ----
type Unit<-T: Type> is Data:
U{}
type In is Data:
Mk{}
def idt(~A: Type, x: A) -> A:
x
def main() -> In:
idt(~In, Mk{})
# ---- word.bend ----
type Bit is Data:
True{}
False{}
type Word is Data:
WNil{}
WCon{h: Bit, t: Word}
type Box is Data:
U32{d: Word}
def main() -> Box:
7bend --version
bend 2.0.35 (source checkout of main at 565d7fd, bun bend2/main.ts); identical on 2.0.32
uname -sm
Linux x86_64
clang --version (the first line)
No response
safe.ts writes two names into the book it emits and looks both up in the user's book. With import Base
anywhere, both are Base's, because parse_fresh refuses a redeclaration. A book with no import Base may
declare its own versions of Base's types (CHANGELOG 2.0.18, #870/#875: such a book "checks and runs"). There,
each name means whatever the user's book has under it, or nothing.
model_at's model of a kind. A root with a ~ parameter gets an opaque constant and asks model for a
value of the parameter's type
(safe.ts#L213-L218).
For a kind, that value is a bare book key, looked up in e.mb, which prototype-chains to the user's
top-levels (L147):
case "Typ": {
return B.ADT("Unit", []); // L435-L436
}
...
case "ADT": {
const tld = e.mb.tlds[F.k] as ADT; // L444
...tld.c.filter(...) // L446(safe.ts#L435-L446.)
Nothing checks that Unit exists, is a datatype or takes no parameters:
- In
crash.bend,~z : Ais typed by the first parameter. Its model reducesAto the made-up
ADT("Unit", [])and re-enters theADTcase, wheree.mb.tlds["Unit"]isundefined(or aDef),
and L446 throws. - In
unit_param.bend,ADT("Unit", [])gives zero arguments to a one-parameter datatype. That is a
type-level function where a type is required. - With one
~and noUnit,term's ownADTcase catches it
(L813-L816),
and the def goes out of scope as "an unknown datatype Unit", a name the user never wrote.
When the user's Unit has the right shape, it is used as is. A zero-constructor Unit makes the model of
~A : Type an empty type. The lookup also crosses files: a Base-free entry's Unit models an imported
module's ~ parameter.
word_ref's type for a word literal. A U32/F32 literal goes out as a def of its own, typed at
item_ref(e, T, …), where T is the literal's constructor name
(safe.ts#L1156-L1166,
called at L1134). A constructor name isn't a top-level name. In the other branch, ctr_term finds the
family with B.book_fam(e.book, x.k)
(L1136).
The two agree only because Base names both U32
(base.bend#L57-L58).
In word.bend the family is Box, so item_ref(e, "U32") finds no top-level. With a def U32, the
literal is typed at that def.
Suggested fix (tested on a copy of 7d24b8d).
case "Typ": {
- return B.ADT("Unit", []);
+ return e.book.tlds["Unit"]?.b === true ? B.ADT("Unit", []) : null;
}
@@
case "ADT": {
const key = B.term_key(B.term_lower(F, d));
- const tld = e.mb.tlds[F.k] as ADT;
+ const tld = e.mb.tlds[F.k];
+ if (tld?.$ !== "ADT") {
+ return null;
+ }
@@ word_ref
- e.out.push([k, { $: "Ref", k: item_ref(e, T, [], false) }, v, false]);
+ e.out.push([k, { $: "Ref", k: item_ref(e, B.book_fam(e.book, T), [], false) }, v, false]);.b === true is the Base flag (bend.ts#L1014-L1018).
check-lit already uses the same test for the same reason
(bend.ts#L3559).
book_fam is the identity on Base's U32 and F32. Results with the patch:
crash.bend,word.bendandword_def.bendpass--verdict.unit_param.bendgoes out of scope withno model for idt~A. Anullmodel already takes this path,
and a Base-free book with noUnitalready goes out of scope today.- All 100 files in
tests/anddemos/that use~give byte-identical-ooutput and the same
messages. So does a 75-file sample of files with number literals, 20 of which mint word defs.
To keep Base-free ~ : Type roots emitting, one option is to mint a one-constructor datatype for the kind
model in place of the null, under a name the user can't take, the way root_cols already mints its
k~p constants (L209-L214). (Not tested.)
#1330 is the same missing guard in the long-Nat split (safe.ts:843-849). #1331 is the bend.ts side:
sugar names (!=, exs, literals) written as bare keys.
Limits. Not a proof of Empty. The kernel checks every def it is given and rejects the ill-typed ones
above. A Base-free book has no Base Empty, and the empty-Unit model certifies a valid book.
Activity
Giulio2002 commentedon Oct 8, 2026
Residual state on 2.0.36 (commit 1d895ca), re-verified in isolation: the raw
TypeErrorcrash paths from this issue are fixed — thank you. What remains is the same class surfacing as the clean mismatch banner on two shapes that now also have repo tests (which pin the fast lane only):tests/check/safe_parameterized_unit.bend(a live~A: Typetemplate instantiation with no nullaryUnitin the book):bend f.bendruns (Mk{}, exit 0),bend f.bend --verdictprints the Sorry banner. Adding a nullarytype Unitorimport Basemakes the identical file pass both lanes. If it helps pin the model lookup: safe.ts'smodel_atTyp arm appears to accept only a nullary ADT literally namedUnit.tests/check/safe_parameterized_box_word.bend(a word literal typed at a parameterized datatype, Base-less):bend f.bendprints7(exit 0),--verdictreports out of scope ("a word literal of a parameterized datatype") and the Sorry banner. Withimport Base, bend2 itself rejects the literal, so the divergence only exists in the Base-less world:A model plainly exists in both cases (the controls pass all lanes), which is what separates these from
tests/proof/model_false.bend/model_no_base.bend. No action expected if this is already inside the "Sorry banner" bucket the kernel tracks — this comment is mainly to record that the twosafe_parameterized_*check tests currently sit on the bend2-only side of that bucket.Found by an automated AI-model differential-testing campaign against bend 2.0.36 (commit 1d895ca): the full 1,598-file test corpus was swept through both
bendandbend --verdict, and every disagreement was re-verified in isolation (the sweep found only these two classes beyond the two known model files and the CHANGELOG-acknowledged #1151 fuel case).