cmd+selfhost+test: predeclare nomem in universe scope
Per Hare convention, `nomem` is a language-level error type — no
import required, in scope alongside void/done/rune/str. ref/hare uses
it bare at errors/string.ha:14, types/c/strings.ha:89, net/uri/parse.ha:17
with no `use`. Precondition for graduating the `alloc` builtin to
`(*T | nomem)` returns.
cstage: ty_nomem is NAMED{under=ty_void, iserror=1}, installed by
typesinit and surfaced via lookup_builtin. wwstage seeds the same
shape in both check.ww (scope) and cgen.ww (aliases) — separate
tables, both consulted; without the cgen seed wwstage drops the
zero-init for `let e: nomem;` locals and breaks byte-identity.
Tests: tagged_ptr_ret.ww and trypromote.ww drop their local
`type nomem = !void;` aliases. 990_selfhost.c adds a regression that
a value named `nomem` does not collide with the predeclared type.
This commit is contained in:
@@ -447,6 +447,16 @@ probe_ww_compile(const char *bin)
|
||||
" o.p = in_;\n"
|
||||
" return o.p.val: i32;\n"
|
||||
"};", 42 },
|
||||
/* #29: `nomem` predeclared in the universe scope as a TYPE
|
||||
* must not block a value of the same name. scope_lookup is
|
||||
* kind-aware, so `let nomem: i32 = 42;` shadows the type in
|
||||
* value position. Byte-identity vs cstage proves both stages
|
||||
* route the value-position lookup past the universe-scope
|
||||
* type seed. */
|
||||
{ "fn main() i32 = {\n"
|
||||
" let nomem: i32 = 42;\n"
|
||||
" return nomem;\n"
|
||||
"};", 42 },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
char rt[1024];
|
||||
|
||||
Reference in New Issue
Block a user