green(reify): implement reify(.enum) — mint a flat enum from TypeInfo
REIFY Phase 0.2 (Phase 0 complete). Lowering.reifyType (lower/nominal.zig)
reads the flat-enum TypeInfo literal off the AST, synthesizes an
ast.EnumDecl, and feeds it through the SAME type_bridge.buildEnumInfo
path source enums use — so the minted type is byte-identical to a
hand-written `enum { value: i64; closed; }` and flows through enum
codegen (layout / construct / match) UNMODIFIED (Contract 2).
Wired at the `E :: reify(...)` const-decl hook in lower/decl.zig
(replacing the Phase-0.0 loud bail). Unsupported argument shapes bail
loudly via reifyBail — never a silent default. The generic.zig inline
reify path now reports it's only supported in a `::` binding (Phase 0).
examples/0614 green: reify a {value: i64, closed} enum, construct
.value(3) and .closed, match both -> "value 3" / "closed". Full suite
green (670 examples, 447 unit).
This commit is contained in:
@@ -651,15 +651,15 @@ pub fn scanDecls(self: *Lowering, decls: []const *const Node) void {
|
||||
.field_access => |fa| fa.field,
|
||||
else => "",
|
||||
};
|
||||
// `E :: reify(...)` — mint a nominal type from a `TypeInfo`
|
||||
// and register `E` as an alias to it. The interpreter-side
|
||||
// construction lands in Phase 0.2; until then bail LOUDLY
|
||||
// and poison `E` to `.unresolved` (so downstream `E.value`
|
||||
// gets a clean follow-on, not a silent default type).
|
||||
// `E :: reify(...)` — mint a NEW nominal type from a
|
||||
// `TypeInfo` literal and register `E` as an alias to it.
|
||||
// `reifyType` builds the type (or diagnoses + returns null);
|
||||
// either way `E` is bound (to the minted type, or poisoned
|
||||
// to `.unresolved` so downstream `E.value` gets a clean
|
||||
// follow-on rather than a silent default type).
|
||||
if (std.mem.eql(u8, callee_name, "reify")) {
|
||||
if (self.diagnostics) |d|
|
||||
d.addFmt(.err, cd.value.span, "reify is not yet implemented (REIFY Phase 0.2)", .{});
|
||||
self.putTypeAlias(self.current_source_file, cd.name, .unresolved);
|
||||
const tid = self.reifyType(cd.name, call_data) orelse TypeId.unresolved;
|
||||
self.putTypeAlias(self.current_source_file, cd.name, tid);
|
||||
continue;
|
||||
}
|
||||
// A namespaced callee (`ns.Box(..)`) is an explicit qualified
|
||||
|
||||
Reference in New Issue
Block a user