Files
sx/examples/diagnostics/1179-diagnostics-comptime-type-construction-bail.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

31 lines
1.3 KiB
Plaintext

// A comptime type construction (declare/define, reflection) that leaves a type
// INCOMPLETE must surface a build-gating DIAGNOSTIC naming the reason — not
// poison the decl to `.unresolved` silently and let that crash at LLVM emission
// or hide behind a downstream cascade. Here `declare("Undefined")` mints a
// forward nominal slot that is NEVER completed by a matching `define(handle, …)`;
// the compiler rejects the incomplete type at its construction site (exit 1, no
// panic).
//
// NOTE: an EXPLICITLY-defined empty type (empty struct/tuple/enum/tagged_union)
// is VALID — see examples/0641. The remaining rejection is purely the
// never-defined `declare` placeholder, which would otherwise panic codegen
// (`verifySizes`: llvm_size != ir_size on an unsized forward slot).
//
// Regression (issue 0140): before the fix this panicked with "unresolved type
// reached LLVM emission" (exit 134), because the interp's bail detail was
// dropped (`catch return null`) and `.unresolved` reached codegen unannounced.
#import "modules/std.sx";
#import "modules/std/meta.sx";
// Declared but never `define`d — an incomplete forward slot.
mk_undefined :: () -> Type {
return declare("Undefined");
}
Undefined :: mk_undefined();
main :: () -> i32 {
u : Undefined = ---;
return 0;
}