P5.7 Step D: re-express metatype define() as sx over register_type
define(handle, info) is now an ordinary sx fn in modules/std/meta.sx: it matches the TypeInfo union and calls the abi(.compiler) register_type primitive with the matching kind code, decoding the variant/field/element list into []Member. An all-void enum variant set registers as kind 2 (actual enum); any payload variant as kind 3 (tagged_union). To support matching the TypeInfo VALUE in the comptime VM, added tagged-union value support: kindOf now treats tagged_union as a by-address aggregate, enum_tag reads the tag word at offset 0, and a new enum_payload arm reads the active payload at tag_size (both bail loudly on backing_type unions, whose layout differs). register_type's duplicate-name diagnostics now include the offending name. Dropped the define interception in tryLowerReflectionCall; the .enum(...) arg infers TypeInfo from the sx fn's param type via the ordinary call path. Regenerated 1179/1180 diagnostic snapshots (same span/line; the message now names register_type instead of define()). define/type_info builtins still exist pending dead-code removal.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
error: comptime type construction failed: comptime define(): enum has no variants
|
||||
error: comptime type construction failed: comptime register_type: a type with no members is never valid
|
||||
--> examples/1179-diagnostics-comptime-type-construction-bail.sx:14:10
|
||||
|
|
||||
14 | Empty :: define(declare("Empty"), .enum(.{ variants = .[] }));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
error: comptime type construction failed: comptime define(): duplicate variant name 'value'
|
||||
error: comptime type construction failed: comptime register_type: duplicate member name 'value'
|
||||
--> examples/1180-diagnostics-metatype-duplicate-variant.sx:8:8
|
||||
|
|
||||
8 | Bad :: define(declare("Bad"), .enum(.{ variants = .[
|
||||
|
||||
Reference in New Issue
Block a user