Second slice of the re-architecture — the compiler now has ZERO type- construction code beyond declare/define. - instantiateTypeFunction: a type-fn body returning a computed Type (a call to a non-generic, bodied, Type-returning fn) is comptime-evaluated with the type bindings active, then renamed to the mangled instantiation name for identity (renameNominalType). Replaces the old reify-call pattern-matching. - DELETED: reifyType (lower/nominal.zig), findReturnReifyCall (lower/generic.zig), and the stale inline-position reify gate in resolveTypeCallWithBindings. - evalComptimeType (was evalComptimeTypeNamed): pure eval, no rename; the type-fn caller renames explicitly. renameReifiedType → renameNominalType. - The TYPE NAME now travels in the data: EnumInfo gains `name`, and define() names the slot from it (the compiler derives no name from a binding LHS). examples/0614/0615 carry `name = "..."`; RecvResult/TryResult set it too. - field_type stays a reflection #builtin (reads a type); only construction moved out. All reify mentions stripped from compiler source. examples 0614/0615/0617 run on the floor. Full suite green (673).
30 lines
932 B
Plaintext
30 lines
932 B
Plaintext
// REIFY Phase 0: mint a NEW nominal enum from a `TypeInfo` value at comptime,
|
|
// then construct one of its variants and match on it — exercising that a
|
|
// reify'd enum (with NO backing AST decl) flows through enum codegen unmodified
|
|
// (layout / construct / match), Contract 2.
|
|
//
|
|
// The enum has two variants: `value` carrying an i64 payload, and `closed` with
|
|
// no payload (`payload = void`).
|
|
#import "modules/std.sx";
|
|
#import "modules/std/meta.sx";
|
|
|
|
E :: reify(.enum(.{ name = "E", variants = .[
|
|
EnumVariant.{ name = "value", payload = i64 },
|
|
EnumVariant.{ name = "closed", payload = void },
|
|
] }));
|
|
|
|
main :: () -> i32 {
|
|
e := E.value(3);
|
|
if e == {
|
|
case .value: (v) { print("value {}\n", v); }
|
|
case .closed: { print("closed\n"); }
|
|
}
|
|
|
|
c : E = .closed;
|
|
if c == {
|
|
case .value: (v) { print("value {}\n", v); }
|
|
case .closed: { print("closed\n"); }
|
|
}
|
|
return 0;
|
|
}
|