comptime VM: flip Type to .type_value; migrate the .any refs that mean a Type value
type_resolver "Type" -> .type_value; const_type result + emitConstType now a bare 8-byte i64 handle (not a 16-byte Any box). Migrated every .any ref meaning "a Type value", leaving real boxed-Any refs: - "Any holds a Type" meta-marker tag .any -> .type_value at all 4 consumers (reflectArgTypeId, reflectTypeId, the comptime type_tag-as-struct path, resolveTypeCategoryTags "type"). - reflection-builtin return types (type_of/declare/define) -> .type_value; runtime type_of(any) reads the tag as a .type_value (no re-box). - expr_typer: a bare type-name expr is .type_value (backtick is_raw exempt). - reflectionArgIsType accepts .type_value OR .any (a reflection arg can be a bare Type or a boxed Any). - comptime switch_br accepts a .type_tag discriminant (type-category match). - a bare function name in a Type slot -> const_type(its function type), not a func-ref (fixes a JIT crash); old string-box kept only for genuine Any params. - field-not-found diagnostic + formatTypeName render .type_value as "Type". Fixed 3 unit tests asserting the old .any behavior. 697/0 both gates (gate ON bails cleanly to legacy since the VM doesn't model Type values yet) + 494 unit tests. 24 snapshots regenerated (22 .ir const_type shape; 2 .stderr Any->Type).
This commit is contained in:
@@ -454,11 +454,12 @@ pub const Builder = struct {
|
||||
/// fail loudly rather than silently materialise the TypeId as an
|
||||
/// int.
|
||||
pub fn constType(self: *Builder, tid: TypeId) Ref {
|
||||
// Type values are Any-shaped at runtime —
|
||||
// `{ tag = .any.index() (the meta-marker), value = tid }`.
|
||||
// Matches `Type → .any` in `type_bridge`. The interp keeps
|
||||
// the high-fidelity `.type_tag` Value for comptime ops.
|
||||
return self.emit(.{ .const_type = tid }, .any);
|
||||
// A Type value is its own 8-byte builtin handle (`.type_value`), a bare
|
||||
// i64 carrying `tid.index()` — distinct from the 16-byte boxed `.any`.
|
||||
// Flowing it into an `Any` slot boxes it (`{ tag = .any.index(), value =
|
||||
// tid }`) via the standard box-any coercion. The interp keeps the
|
||||
// high-fidelity `.type_tag` Value for comptime ops.
|
||||
return self.emit(.{ .const_type = tid }, .type_value);
|
||||
}
|
||||
|
||||
// ── Arithmetic ──────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user