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:
@@ -5,22 +5,19 @@
|
||||
// while wwstage emitted the documented general tagged-return ABI
|
||||
// (AX=tag, DX=word0). Per CLAUDE.md rule 10 the richer side aligns DOWN —
|
||||
// cstage now restricts the nullable fold to literal `void` variants, so
|
||||
// `(*T | nomem)` (`type nomem = !void;`) takes the general path on both
|
||||
// stages and the 993/995 byte-identity tests stay green once #17 lands a
|
||||
// (*T | nomem) signature in lib/.
|
||||
// `(*T | nomem)` takes the general path on both stages and the 993/995
|
||||
// byte-identity tests stay green.
|
||||
//
|
||||
// nomem is declared locally because it is not yet predeclared in the
|
||||
// universe scope (that move is #17). Two match arms cover both runtime
|
||||
// outcomes — success unwrap (tag=0, ptr payload in DX) and error
|
||||
// propagation (tag=1) — exercising the same AX/DX ABI both stages must
|
||||
// agree on.
|
||||
// Task #29: `nomem` is now predeclared in the compiler universe scope, so
|
||||
// neither `import errors;` nor a local `type nomem = !void;` is needed.
|
||||
// Two match arms cover both runtime outcomes — success unwrap (tag=0,
|
||||
// ptr payload in DX) and error propagation (tag=1) — exercising the
|
||||
// same AX/DX ABI both stages must agree on.
|
||||
|
||||
package test;
|
||||
|
||||
import fmt;
|
||||
|
||||
type nomem = !void;
|
||||
|
||||
fn alloc1(fail: i64) (*u8 | nomem) = {
|
||||
if (fail != 0i64) { let e: nomem; return e; };
|
||||
let buf: [1]u8;
|
||||
|
||||
@@ -17,7 +17,8 @@ package test;
|
||||
|
||||
import fmt;
|
||||
|
||||
type nomem = !void;
|
||||
// #29: `nomem` is predeclared in the universe scope — no local
|
||||
// `type nomem = !void;` (or `import errors;`) needed.
|
||||
|
||||
fn stub(fail: i64) (i64 | nomem) = {
|
||||
if (fail != 0i64) { let e: nomem; return e; };
|
||||
|
||||
Reference in New Issue
Block a user