xfail(reify): examples/0614-comptime-reify-enum — reify a flat enum
REIFY Phase 0.1. Add the end-to-end Phase-0 example: reify a flat enum (value: i64, closed) from a TypeInfo literal, construct E.value(3) / E.closed, and match both arms. Seed an empty expected/*.exit marker. RED by design (reify still bails -> "unparseable expected exit"); the next commit (0.2) implements reify and turns it green. Satisfies the no-commit-both-adds-a-test-and-passes cadence.
This commit is contained in:
29
examples/0614-comptime-reify-enum.sx
Normal file
29
examples/0614-comptime-reify-enum.sx
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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(.{ 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;
|
||||
}
|
||||
0
examples/expected/0614-comptime-reify-enum.exit
Normal file
0
examples/expected/0614-comptime-reify-enum.exit
Normal file
Reference in New Issue
Block a user