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:
2026-05-19 19:50:38 +09:00
parent ea76ee4aa3
commit d27411d833
10 changed files with 146 additions and 11 deletions

View File

@@ -53,6 +53,7 @@ lookup_builtin(const char *name)
if (strcmp(name, "f64") == 0) return ty_f64;
if (strcmp(name, "str") == 0) return ty_str;
if (strcmp(name, "never") == 0) return ty_never;
if (strcmp(name, "nomem") == 0) return ty_nomem; /* #29 */
return NULL;
}