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
C backend rejects case-distinct constructors because both names become the same CID macro #989
bun bend2/main.ts case-folded-ctor.bend -o /tmp/case-folded-ctor.c
The same file evaluates normally and emits working JavaScript:
bun bend2/main.ts case-folded-ctor.bend
bun bend2/main.ts case-folded-ctor.bend -o /tmp/case-folded-ctor.js
bun /tmp/case-folded-ctor.js
What happened
The evaluator and emitted JavaScript both print:
done{}
The C emitter refuses the same checked program:
Error: two names mangle to CID_DONE
Base declares the constructor Done, while this file declares the distinct constructor done. Bend accepts both names and the evaluator and JavaScript backend keep them distinct. The C backend builds a constructor macro with "CID_" + name_clean(k).toUpperCase(), so both source names become CID_DONE. The duplicate check then aborts emission. comp.ts:1537-1539, comp.ts:2903-2910
This is related to the name-mangling collision class in #790 and #799, but it occurs in the constructor ID table rather than the JavaScript definition table or FFI effect table. The collision is detected, so I have not observed wrong code or a soundness failure; the result is that a valid program supported by the evaluator and JavaScript backend cannot be compiled to C.
The file
import Base
type Lower is Data:
done{}
def main() -> Lower:
done{}
Expected behavior
Case-distinct Bend constructor names should receive distinct C identifiers, or the frontend should reject the unsupported naming combination before backend selection.
Environment
bend version: bend 2.0.25
commit: a49524265bdfa5753a4bf38e25f0574a705dd868
uname -sm: Darwin arm64
clang --version: Apple clang version 21.0.0 (clang-2100.0.123.102)
Activity
A name is words joined by dots, a namespace is the file's real path, …