From 310461f651649ee6bb9df74bcade7ec924a9cec4 Mon Sep 17 00:00:00 2001 From: agra Date: Fri, 19 Jun 2026 21:45:27 +0300 Subject: [PATCH] =?UTF-8?q?checkpoint:=20P5.7=20done=20=E2=80=94=20comptim?= =?UTF-8?q?e=20VM=20is=20the=20sole=20evaluator,=20zero=20legacy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update CHECKPOINT-COMPILER-API: Resume banner + Log entries for Step D (metatype declare/define re-expressed as sx over the compiler-API) and the empty-member-types-valid change. 709/0 corpus + 476/476 unit. --- current/CHECKPOINT-COMPILER-API.md | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/current/CHECKPOINT-COMPILER-API.md b/current/CHECKPOINT-COMPILER-API.md index 0bc8b7af..97b9bf68 100644 --- a/current/CHECKPOINT-COMPILER-API.md +++ b/current/CHECKPOINT-COMPILER-API.md @@ -8,6 +8,21 @@ with ONE welded mechanism. Branch: `reify` (off `master`). Update after every st ## ⏯ Resume (fresh session) +> **✅ P5.7 DONE (2026-06-19) — the comptime VM is the SOLE evaluator; ZERO legacy.** `interp.zig` (the legacy +> tagged-`Value` Interpreter) is DELETED; the `Value` result-DTO + `regToValue` materialization live in +> `comptime_value.zig` (the VM↔host boundary), `valueToReg` is gone. NO fallback anywhere — a VM bail is always a +> build-gating diagnostic (emit-time `#run`/const-init, lowering-time type-fn, `#insert`, inline comptime-call +> fold all run on the VM only). `#compiler` attribute + `compiler_call` IR op + `compiler_hooks` `Registry`/`HookFn` +> + all `hookXxx` are DELETED (`compiler_hooks.zig` keeps only `BuildConfig`/`BuildHooks`/`AssetDir`); `compiler_lib` +> is just the name registry now. The metatype `declare`/`define` are sx over the compiler-API (`declare_type`/ +> `register_type`); `type_info`/`field_type` stay builtins (documented). Bonus this arc: fixed issue 0141 (reject +> the silent `[*]T → []T` coercion; land the corrected List-grown form 0640 + diagnostic 1183); empty-member types +> are valid for all kinds (0641; never-defined `declare` still rejected 1179). 1654 reconciled to the VM wording. +> **709/0 corpus + 476/476 unit, green; commits on `reify` from `5d25e23` (Step A) through `5383496`.** +> REMAINING TAIL (P5.8, needs hardware/SDK): iOS-device + Android bundle validation + an `.apk` corpus smoke test. +> OPTIONAL follow-up: re-express `type_info` as sx (reflect-into-value; kept as builtin to protect the 0619/0622/ +> 0623 round-trips). See the newest `## Log` entries. +> > **⚠ DIRECTION CHANGED (2026-06-17). The active plan is now > [`PLAN-COMPILER-VM.md`](PLAN-COMPILER-VM.md), NOT the weld.** > The **byte-weld + serialization/marshaling** approach is the wrong direction and is @@ -431,6 +446,35 @@ when reached (sentinels or accessor fns; see the design doc Risks). `List` growth; orthogonal, see `current/CHECKPOINT-METATYPE.md`.) ## Log +- **Empty-member types are VALID for all kinds (user design decision, 2026-06-19).** A comptime-constructed type + with NO members now mints for every kind (empty `struct`, empty `tuple`/unit, empty `enum`, empty + `tagged_union`); ONLY a bare `declare("X")` never completed by a `define` stays rejected. `registerTypeVm` + dropped the blanket "a type with no members is never valid" bail (the per-kind loops are vacuous for an empty + list). To distinguish an EXPLICITLY-defined empty union from a never-defined `declare` PLACEHOLDER (both are + 0-field `tagged_union`s), added `defined: bool = true` to `TaggedUnionInfo` — default true for every real + construction (normal unions, error sets, `register_type` completion); set false ONLY at the two declare- + placeholder sites (`comptime_vm.declareNominal`, `lower/comptime.preregisterForwardTypes`). + `checkComptimeTypeResult` now rejects on `!defined` (not `fields.len == 0`). Codegen parity fix: + `typeSizeBytes(tagged_union)` floors the payload area at 8B when no field carries a payload, mirroring the LLVM + lowering (`backend/llvm/types.zig`) — fixes a `verifySizes` panic on an empty/all-void tagged_union. Tests: + `examples/1179` repurposed from "empty enum rejected" (now valid) to the never-defined `declare` case + (preserves its issue-0140 "diagnostic-not-panic" regression role); `examples/1180` (duplicate variant) + unchanged; new `examples/0641-comptime-empty-types-valid` constructs all four empty kinds. **709/0 corpus + + 476/476 unit** (`5383496`). +- **P5.7 Step D — re-expressed the metatype `declare`/`define` as sx over the compiler-API (2026-06-19).** + `declare(name)` → sx `{ return declare_type(name); }`; `define(handle, info)` → sx that matches the `TypeInfo` + union and calls `register_type(handle, kind, members)` (kinds 1/2/3/4). DELETED the bespoke `callBuiltinVm` + `.declare`/`.define` arms + the `defineFromInfo`/`decodeTypeSlice` helpers + the `declare`/`define` `BuiltinId` + enum members + their `tryLowerReflectionCall` interceptions. The metatype DSL now rides the ONE compiler-API + mechanism (`register_type`/`declare_type`, serviced by `callCompilerFn`), with the DSL in `meta.sx`. Supporting + VM change: tagged-union VALUE support so the sx `define` can `match` a `TypeInfo` (`kindOf` treats + `tagged_union` as a by-address aggregate; `enum_tag` reads the tag word; new `enum_payload` arm; all bail loudly + on a `backing_type` union). **KEPT as builtins (documented):** `type_info($T)` (reflects a type INTO a + byte-compatible `TypeInfo` value — `buildTypeInfo`; re-expressing risks the 0619/0622/0623 round-trips for no + proportional gain) and `field_type($T, idx)` (a LOWER-time fold in `generic.zig`, so it composes inside type-arg + slots — never was a `callBuiltinVm` arm). Diagnostics 1179/1180 regenerated (now name `register_type`). + **708/0 corpus + 476/476 unit** (`8850fcc`/`7b1d8ce`/`ccba704`). Net: 2 of 4 metatype builtins are now sx; the + bespoke Zig metatype surface shrank by two `callBuiltinVm` arms, two helpers, and two `BuiltinId`s. - **P5.7 Step C — DELETED `interp.zig` (the legacy tagged-`Value` interpreter); the VM is the SOLE comptime evaluator (2026-06-19).** Five green commits. **C1** (`#insert` → VM): `evalComptimeString` was the last caller of `Interpreter.call`; routed through `comptime_vm.tryEval` (the VM bails-not-panics on malformed