fix(0140): surface comptime type-construction bail as a diagnostic

evalComptimeType did `interp.call(...) catch return null`, dropping the
interp's last_bail_detail; callers poisoned to .unresolved with no
diagnostic, so the sentinel reached LLVM emission and panicked
("unresolved type reached LLVM emission"), or hid behind a downstream
cascade.

Clear last_bail_detail before the call; on the catch emit a build-gating
.err at the construction expr's span ("comptime type construction
failed: {detail}", mirroring the #run surfacing in emit_llvm.zig), then
return null to keep the .unresolved poison — now gated by a real message
so no unresolved type reaches emission unannounced.

Empty-variant define now prints 'comptime define(): enum has no
variants' and exits 1 (no panic); make_enum-style computed-slice
failures show their root reason at the construction site.
This commit is contained in:
agra
2026-06-17 04:31:38 +03:00
parent 3a062780f7
commit 37ec3da8cb
2 changed files with 35 additions and 1 deletions

View File

@@ -1,5 +1,21 @@
# 0140 — a failing comptime type construction panics ("unresolved type reached LLVM emission") instead of diagnosing the bail
> **RESOLVED (2026-06-17).** Root cause exactly as the investigation prompt
> hypothesized: `evalComptimeType` (`src/ir/lower/comptime.zig`) did
> `interp.call(...) catch return null`, dropping the interpreter's
> `last_bail_detail`; callers poisoned to `.unresolved` with no diagnostic, so the
> sentinel reached LLVM emission and tripped the codegen panic (or hid behind a
> downstream cascade). Fix: clear `Interpreter.last_bail_detail` before the call,
> and on the `catch` emit a build-gating `.err` at the construction expression's
> span — `"comptime type construction failed: {detail}"` (mirroring the `#run`
> surfacing at `emit_llvm.zig:856`) — then return null (keeping the `.unresolved`
> poison, now gated by a real message). The empty-variants repro now prints
> `comptime type construction failed: comptime define(): enum has no variants`
> and exits 1 (no panic); make_enum-style computed-slice failures surface their
> root reason at the construction site instead of only the `.green` cascade.
> Regression test:
> [examples/1179-diagnostics-comptime-type-construction-bail.sx](../examples/1179-diagnostics-comptime-type-construction-bail.sx).
## Symptom
One-line: when a comptime type construction (`declare`/`define`) bails in the