feat(metatype): widen type_info/define to tuple types

TypeInfo gains a `tuple(TupleInfo) variant (TupleInfo{elements: []Type},
positional/unnamed) — completing the reflect/construct triad with enum
and struct.

- meta.sx: TupleInfo + `tuple TypeInfo variant.
- interp: reflectTypeInfo builds .tuple (tag 2) as bare type_tag elements
  (no name pairs); defineType dispatches tag 2 -> defineTuple, which
  decodes []Type and completes the declare slot as a structural .tuple
  via replaceKeyedInfo (kind change). Tuples are structural so the
  declared name is vestigial, but the slot is still completed in place so
  define returns the handle (consistent with enum/struct).
- call.zig: the lower-time type_info guard now admits .tuple.

define(declare("P"), .tuple(.{elements=.[i64,f64]})) builds a tuple, and
define(declare("T"), type_info((i64,bool,f64))) round-trips one. Suite
green (683).
This commit is contained in:
agra
2026-06-17 07:05:55 +03:00
parent d83f5fa90d
commit 9f3f746c4b
3 changed files with 54 additions and 7 deletions

View File

@@ -35,14 +35,21 @@ StructInfo :: struct {
fields: []StructField;
}
// The element types of a tuple being reflected or constructed. Tuples are
// POSITIONAL (no field names), so this is just an ordered list of types.
TupleInfo :: struct {
elements: []Type;
}
// The reflected/constructed type shape. A tagged union over the kinds of type
// that can be minted — `` .`enum `` and `` .`struct `` ship today (tuple later).
// that can be minted — `` .`enum ``, `` .`struct `` and `` .`tuple `` all ship.
// The variants use the backtick raw-identifier escape so they read as the
// keywords `enum` / `struct` (`` .`enum(...) `` / `` .`struct(...) ``) rather than
// mangled `enum_` / `struct_`.
// keywords (`` .`enum(...) `` / `` .`struct(...) `` / `` .`tuple(...) ``) rather
// than mangled `enum_` / `struct_` / `tuple_`.
TypeInfo :: enum {
`enum: EnumInfo;
`struct: StructInfo;
`tuple: TupleInfo;
}
// The compiler's ONLY type-construction primitives (comptime-only #builtins):