What you did
bun bend2/main.ts proto_type.bend --check-only
bun bend2/main.ts proto_type.bend
bun bend2/main.ts proto_type.bend -o out.js
bun bend2/main.ts proto_type.bend -o out
proto_type.bend:
import Base
type __proto__ is Data:
P{}
def main() -> __proto__:
P{}
What happened
The checker accepts the file and the interpreter prints the expected value:
Both the JS and native build paths instead fail inside the compiler:
TypeError: undefined is not an object (evaluating 'lay.ks.length')
Why it happens
WORDS is a normal object, but datatype names are used to query it without an own-property check:
const WORDS: Record<string, Lay> = { U32: W32, F32: W32, Nat: W64 };
function lay_of(book: Bend.Book, A: HTerm | null): Lay {
const t = ty_adt(book, A);
if (t === null) {
return BOX;
}
return WORDS[t.k] ?? memo(LAYS, A!, () => {
For __proto__, WORDS[t.k] returns the inherited Object.prototype rather than undefined, so lay_of returns a value that is not a Lay; the printer/layout path later reads its nonexistent ks. The same bug reproduces with datatypes named constructor and toString, confirming that this is the inherited-property class rather than a special parser case.
The compiler already gives the user-indexed OPERATIONS and OPTIMIZED tables null prototypes. WORDS needs the same treatment, or each lookup needs to require an own property.
This also reproduces on 2.0.23, so it is not a 2.0.24 regression.
bend --version
bend 2.0.24
commit 99f9c6cd
uname -sm
clang --version (the first line)
Apple clang version 21.0.0 (clang-2100.0.123.102)
What you did
proto_type.bend:What happened
The checker accepts the file and the interpreter prints the expected value:
Both the JS and native build paths instead fail inside the compiler:
Why it happens
WORDSis a normal object, but datatype names are used to query it without an own-property check:For
__proto__,WORDS[t.k]returns the inheritedObject.prototyperather thanundefined, solay_ofreturns a value that is not aLay; the printer/layout path later reads its nonexistentks. The same bug reproduces with datatypes namedconstructorandtoString, confirming that this is the inherited-property class rather than a special parser case.The compiler already gives the user-indexed
OPERATIONSandOPTIMIZEDtables null prototypes.WORDSneeds the same treatment, or each lookup needs to require an own property.This also reproduces on 2.0.23, so it is not a 2.0.24 regression.
bend --version
uname -sm
clang --version (the first line)