Files
sx/examples/comptime/0632-comptime-metatype-make-enum-payloadless.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +03:00

32 lines
1.0 KiB
Plaintext

// Regression (issue 0142): a comptime-minted FULLY payloadless enum (every
// variant tagless) must mint as a real `.@"enum"`, not an all-void tagged_union
// — the latter has an IR/LLVM size mismatch that tripped `verifySizes` at
// codegen. `make_enum` (declare/define) with an all-void variant list now
// produces an ordinary enum, usable like a hand-written one.
#import "modules/std.sx";
#import "modules/std/meta.sx";
make_suit :: () -> Type {
return make_enum("Suit", EnumVariant.[
EnumVariant.{ name = "hearts", payload = void },
EnumVariant.{ name = "spades", payload = void },
EnumVariant.{ name = "diamonds", payload = void },
]);
}
Suit :: make_suit();
show :: (s: Suit) {
if s == {
case .hearts: { print("hearts\n"); }
case .spades: { print("spades\n"); }
case .diamonds: { print("diamonds\n"); }
}
}
main :: () {
show(.spades); // leading-dot, typed context
x := Suit.diamonds; // qualified construction
show(x);
}