ReviewOS

home-lang/home

fix(types): distinguish typed undefined storage from null

#826
Closed glennmichael123 opened this 9 days ago ·
9 days ago

The parser currently lowers both null and Zig-style undefined to an indistinguishable NullLiteral. That creates two correctness bugs: the checker rejects var value: T = undefined for non-optional T, while code generation cannot distinguish uninitialized storage from a real null/zero initializer.\n\nScope:\n- represent null and undefined distinctly without expanding the expression union\n- preserve real null optional-only checking\n- let typed undefined adopt its destination type and remain tracked as uninitialized until a proven write\n- ensure code generation reserves storage without manufacturing a zero initialization\n- add focused parser, checker, and lowering coverage\n\nObserved in the current home-os origin/main kernel corpus at src/main.home:66. Tracks #787 and #66.

9 days ago

First direct-to-main slice landed in eafec92: the AST and parser now distinguish typed undefined storage from null without expanding the expression union. Parser tests pass 148/148 and AST tests pass 14/14. The commit contains exactly three files, is authored/committed by Glenn, and has no coauthors. Checker and lowering semantics remain open in this issue.

9 days ago

Checker semantics landed directly on main in ca905a5. Typed undefined now adopts its declared/contextual type, remains in may-uninitialized dataflow until a proven write, and cannot be inferred without a destination. Real null remains optional-only. Verification: 69/69 focused checker tests; guarded no-JSC build at 2,889 MB peak; current archived home-os origin/main corpus improved from 31 to 21 semantic failures. Exactly three files, Glenn author/committer, no coauthors. Lowering semantics remain open.

9 days ago

Completed by direct main commits eafec92, ca905a5, and d7c4a74. The parser preserves null vs typed undefined, the checker requires contextual typing and tracks may-uninitialized reads, and x64/AArch64/kernel lowering reserves storage without emitting a fabricated zero initializer. Verification: parser 148/148, AST 14/14, checker 69/69, codegen 18/18, guarded no-JSC build (2,913 MB peak), and the current archived home-os origin/main corpus improved from 31 to 21 semantic failures. Final commit has exactly five files and all three commits are Glenn-authored/committed with no coauthors.

Sign in to comment on this issue.