comptime VM: model .type_value natively (word); harden struct_init vs arrays
kindOf(.type_value) -> .word; new const_type exec arm -> word = TypeId.index(); regToValue maps a .type_value word back to a .type_tag Value at the legacy boundary. The VM now runs comptime evals involving Type values instead of bailing. This reached a latent VM panic: struct_init assumed a .@"struct" result type and union-access-panicked on an array literal (EnumVariant.[...]). It is the generic aggregate-literal op, so it now dispatches on the result kind (struct/array/ tuple) and bails loudly on anything else — never panics (CLAUDE.md no-panic). 697/0 both gates (make_enum type-fns run further on the VM, then bail cleanly at the define call_builtin -> legacy mints; no mutation before bail). VM unit test added (const_type -> word -> regToValue -> .type_tag).
This commit is contained in:
@@ -335,6 +335,20 @@ when reached (sentinels or accessor fns; see the design doc Risks).
|
||||
`List` growth; orthogonal, see `current/CHECKPOINT-METATYPE.md`.)
|
||||
|
||||
## Log
|
||||
- **Phase 3 P3.4 step 4 (VM plan) — model `.type_value` natively in the comptime VM (2026-06-18).**
|
||||
The VM now HANDLES Type values instead of bailing: `kindOf(.type_value)` → `.word`; a new
|
||||
`const_type` exec arm → the word `TypeId.index()`; `regToValue` maps a `.type_value` word back
|
||||
to a `.type_tag` Value at the legacy boundary (`valueToReg` already mapped `.type_tag` →
|
||||
index). Surfaced + fixed a VM PANIC (forbidden): `struct_init` assumed a `.@"struct"` result
|
||||
type and union-access-panicked on an ARRAY literal (`EnumVariant.[ … ]`, reached now that Type
|
||||
args no longer bail early) — it's the generic aggregate-literal op, so it now dispatches on the
|
||||
result kind (struct / array / tuple) and BAILS loudly on anything else, never panics. **697/0
|
||||
both gates** (the make_enum type-fns now run further on the VM, then bail cleanly at the
|
||||
`define`/`make_enum` `call_builtin` → legacy mints — no mutation before the bail, parity holds).
|
||||
VM unit test added (const_type → word → regToValue → `.type_tag`). On `reify`. **Next (the
|
||||
payoff):** port the WRITE side (declare_type / register_type / pointer_to) into
|
||||
`Vm.callCompilerFn` + give the lowering-time path a REAL Context (CAllocator thunk func-refs,
|
||||
not zeroed) → the first HANDLED lowering-time type-fn end-to-end on the VM.
|
||||
- **Phase 3 P3.4 step 3 (VM plan) — dedicated `Type` builtin TypeId: RESOLVER FLIPPED + `.any` migration (2026-06-18).**
|
||||
Flipped `type_resolver:64` (`"Type"` → `.type_value`), `module.zig` `constType` (result type
|
||||
→ `.type_value`), and `emitConstType` (a bare i64 carrying `tid.index()`, NOT a 16-byte Any
|
||||
|
||||
Reference in New Issue
Block a user