test(metatype): lock declare()-never-defined rejection (examples/1181)
Diagnostics example for the bare-declare guard (14f30f3): an unfinished
declare("Undef") -> build-gating error naming the type, exit 1.
This commit is contained in:
14
examples/1181-diagnostics-metatype-declare-never-defined.sx
Normal file
14
examples/1181-diagnostics-metatype-declare-never-defined.sx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// A `declare("X")` that is never completed by `define(handle, info)` is rejected
|
||||||
|
// loudly. `declare` mints an empty (undefined) nominal slot; without a matching
|
||||||
|
// `define` it has zero variants, which is never a usable type — sizing /
|
||||||
|
// constructing it would otherwise panic at codegen. The diagnostic names the
|
||||||
|
// type and points at the bare `declare` so the missing `define` is obvious.
|
||||||
|
#import "modules/std.sx";
|
||||||
|
#import "modules/std/meta.sx";
|
||||||
|
|
||||||
|
Undef :: declare("Undef"); // never define()d
|
||||||
|
|
||||||
|
main :: () -> i32 {
|
||||||
|
x : Undef = ---;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
error: type 'Undef' is declared but never defined — complete it with define(handle, info)
|
||||||
|
--> examples/1181-diagnostics-metatype-declare-never-defined.sx:9:10
|
||||||
|
|
|
||||||
|
9 | Undef :: declare("Undef"); // never define()d
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
Reference in New Issue
Block a user