comptime VM: strict no-fallback mode — the interp-retirement enumeration gate (Phase 4)

Add -Dcomptime-flat-strict / env SX_COMPTIME_FLAT_STRICT (implies comptime_flat):
at all three comptime sites (type-fn in lower/comptime.zig, const-init + #run in
emit_llvm.zig) a VM bail becomes a build-gating error naming the reason INSTEAD of
falling back to legacy. Forces every comptime eval onto the VM so the complete gap
set is enumerable in one sweep; when the corpus is green under strict mode AND every
example matches legacy, interp.zig can be deleted.

Default behaviour unchanged (699/0 both default gates). Fixed a wiring bug: the
type-fn site's local comptime_flat didn't include the strict flag (every type-fn
falsely reported <unknown>); strict now implies flat there too.

Swept the gap list (19 strict bails): switch_br (5, + unmasks a []Type-across-call
silent-wrong in 0114), compiler_call (6, = the BuildOptions->abi(.zig) extern
compiler migration), out (2), type_name (1), global_addr (1), interp_print_frames
(1), 2 negative-test diagnostics (1179/1180), 1 dlsym (1654). Recorded as the
deletion checklist in CHECKPOINT-COMPILER-API.md.
This commit is contained in:
agra
2026-06-18 19:06:51 +03:00
parent da6a8423c7
commit dcb1392255
4 changed files with 74 additions and 2 deletions

View File

@@ -373,6 +373,35 @@ when reached (sentinels or accessor fns; see the design doc Risks).
`List` growth; orthogonal, see `current/CHECKPOINT-METATYPE.md`.)
## Log
- **Phase 4 — STRICT no-fallback mode (the interp-retirement enumeration gate) + full gap list (2026-06-18).**
Added `-Dcomptime-flat-strict` / env `SX_COMPTIME_FLAT_STRICT` (implies `comptime_flat`): at all
THREE comptime sites (type-fn in `lower/comptime.zig`, const-init + `#run` in `emit_llvm.zig`) a VM
bail becomes a build-gating error naming the reason INSTEAD of falling back to legacy. This forces
every comptime eval onto the VM so the complete gap set is enumerable in one sweep; when the corpus
is green under strict mode AND every example MATCHES legacy, the VM handles everything and
`interp.zig` can be deleted (4F). Default behaviour unchanged — **699/0 both default gates**.
(Fixed a wiring bug: the type-fn site's local `comptime_flat` didn't include the strict flag, so
every type-fn falsely reported `<unknown>`; now strict implies flat there too.)
**THE DELETION CHECKLIST (19 strict bails, swept via `SX_COMPTIME_FLAT_STRICT=1` over examples+issues;
0103/0800 "WRONG" were false positives — raw heap-pointer addresses the corpus normalizes):**
- `switch_br` (5): 0114, 0521, 0522, 0524, 1035 — port the type-category multi-way branch (trivial
jump). **CAUTION:** porting it (+`type_name`) UNMASKS a silent-wrong in 0114 — a `[]Type` slice
materialized when a pack (`$args`) is passed ACROSS A CALL reads its `string` element as
`<unresolved>`. Must fix that VM pack-Type-materialization bug, not just add the op.
- `compiler_call` (6): 0602, 0603, 1604, 1609, 1611, 1615 — the **BuildOptions → `abi(.zig) extern
compiler`** migration (delete `#compiler`/`compiler_call`; thread `BuildConfig` into the VM). Big.
- `out` (2): 0613, 1038 — comptime print. Direct write to fd 1, BUT only safe when the WHOLE eval is
VM-handled (a print-then-bail double-prints under the legacy re-run — 0613). Flip atomically.
- `type_name` (1): 0520 — reflection reader (`.type_value` word / Any-box tag → `table.typeName`).
- `global_addr` (1): 0600 — only `&__sx_default_context` is materialised (mirror legacy).
- `interp_print_frames` (1): 1034 — return-trace frame printing.
- VM-native diagnostics (4B) (2): 1179, 1180 — NEGATIVE tests; the VM bail (`define: enum has no
variants` / `duplicate variant name`) IS the expected outcome → must surface as the proper
build-gating diagnostic, not the generic strict error.
- dlsym not found (1): 1654 — a target-specific `extern` (asm global) called at comptime; likely a
legitimately-unresolvable case → confirm it stays a clean diagnostic.
**Sweep command:** `SX_COMPTIME_FLAT_STRICT=1 ./zig-out/bin/sx run <ex>` per example, diff vs legacy;
a strict bail prints `... bailed on the VM (strict, no fallback): <reason>`.
- **Phase 4D.2 (VM plan) — extern SLICE/string args (→ NUL-terminated `char*`) + float guards (2026-06-18).**
Extracted `marshalExternArg`: a scalar/pointer WORD passes verbatim (a `cstring` arg already works
as a pointer word via 4D.1); a `string`/slice `{ptr,len}` fat pointer is copied into a