From 1bec54d0c4043844f2195112f7bc0727c0d19e1b Mon Sep 17 00:00:00 2001 From: agra Date: Tue, 16 Jun 2026 18:08:00 +0300 Subject: [PATCH] =?UTF-8?q?xfail(reify):=20examples/0614-comptime-reify-en?= =?UTF-8?q?um=20=E2=80=94=20reify=20a=20flat=20enum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- current/CHECKPOINT-REIFY.md | 10 ++++++- examples/0614-comptime-reify-enum.sx | 29 +++++++++++++++++++ .../expected/0614-comptime-reify-enum.exit | 0 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 examples/0614-comptime-reify-enum.sx create mode 100644 examples/expected/0614-comptime-reify-enum.exit diff --git a/current/CHECKPOINT-REIFY.md b/current/CHECKPOINT-REIFY.md index 965d8dba..ff672a64 100644 --- a/current/CHECKPOINT-REIFY.md +++ b/current/CHECKPOINT-REIFY.md @@ -4,7 +4,15 @@ Companion to [PLAN-REIFY.md](PLAN-REIFY.md). Update after every step (one step a time, per the cadence rule). ## Last completed step -**Phase 0.0 (lock).** Added the comptime type-metaprogramming surface as the +**Phase 0.1 (xfail).** Added `examples/0614-comptime-reify-enum.sx` — reify a +flat enum (`value: i64`, `closed`) from a `TypeInfo` literal, construct +`E.value(3)` / `E.closed`, match both. Seeded an EMPTY +`expected/0614-…​.exit` marker → corpus is RED ("unparseable expected exit", +reify still bails). This is the deliberate xfail; **Phase 0.2 turns it green** +(per the no-commit-both-adds-and-passes cadence). `zig build test` is RED on +this commit by design (1 example fails); the very next commit makes it pass. + +### (prior) Phase 0.0 (lock). Added the comptime type-metaprogramming surface as the on-demand module `library/modules/std/meta.sx` (NOT the prelude — see decision below): `EnumVariant`/`EnumInfo`/`TypeInfo` data types + bodyless `#builtin` decls `reify` / `type_info` / `field_type`. Each builtin bails LOUDLY when diff --git a/examples/0614-comptime-reify-enum.sx b/examples/0614-comptime-reify-enum.sx new file mode 100644 index 00000000..98a4a975 --- /dev/null +++ b/examples/0614-comptime-reify-enum.sx @@ -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; +} diff --git a/examples/expected/0614-comptime-reify-enum.exit b/examples/expected/0614-comptime-reify-enum.exit new file mode 100644 index 00000000..e69de29b