fix(reflection): replace silent .s64 arg-type fallback with loud .unresolved (issue 0075)
The `type_name` / `type_eq` reflection builtins resolved their Type arg's IR
type via `getRefIRType(...) orelse TypeId.s64`, then gated `== .any`. A failed
must-succeed lookup silently became `.s64` (`!= .any`), classifying a boxed
`Any` arg as bare i64 and reading the wrong value with no diagnostic.
Add the sibling classifier `LLVMEmitter.reflectArgRepr`, which routes the
lookup through `argIRTypeOrFail` (the issue-0074 `.unresolved` resolver) and
returns `{ boxed, bare, unresolved }`. The three emit sites in ops.zig
(`type_name` + `type_eq` x2) now switch on it: `.boxed` extracts the Any value
field, `.bare` uses the value directly, `.unresolved` hits a hard `@panic`
tripwire — never silently treated as bare. Real args always resolve, so the
happy path is byte-identical (suite stays 361/0, zero snapshot churn).
Secondary `lower.zig` `null_literal`/`undef_literal => target_type orelse .void`
confirmed intentional (typeless-literal default deliberately handled by
emitConstNull/emitConstUndef as null-ptr / undef-i64) — left with an invariant
comment, not the `.unresolved` tripwire.
Regression test in emit_llvm.test.zig asserts the loud path: fail-before with
`orelse .s64` yields `.bare`; pass-after yields `.unresolved`.
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
> **RESOLVED** (2026-06-03)
|
||||
> **Root cause:** the `type_name` / `type_eq` reflection builtins resolved their
|
||||
> `Type` arg's IR type with `getRefIRType(...) orelse TypeId.s64`, then gated `== .any`
|
||||
> — so a failed must-succeed lookup silently became "bare i64" (`.s64 != .any`),
|
||||
> reading the wrong value with no diagnostic.
|
||||
> **Fix:** added the sibling classifier `LLVMEmitter.reflectArgRepr`
|
||||
> (`src/ir/emit_llvm.zig`) which routes the lookup through `argIRTypeOrFail` →
|
||||
> `.unresolved` and returns `{ boxed, bare, unresolved }`. The three emit sites
|
||||
> (`src/backend/llvm/ops.zig` `type_name` + `type_eq` ×2) now `switch` on it: `.boxed`
|
||||
> extracts the `Any` value field, `.bare` uses the value directly, and `.unresolved`
|
||||
> hits a hard `@panic` tripwire — never silently classified as bare. Happy path
|
||||
> (real args always resolve) is byte-identical; suite stays 361/0.
|
||||
> **Secondary (confirmed intentional):** `src/ir/lower.zig:2531/2532`
|
||||
> (`null_literal` / `undef_literal` → `target_type orelse .void`) is a typeless-literal
|
||||
> default, not a lookup-swallow — `emitConstNull`/`emitConstUndef` deliberately handle
|
||||
> `.void` (null-ptr / undef-i64). Left in place with an invariant comment.
|
||||
> **Regression test:** `src/ir/emit_llvm.test.zig` — "emit: reflectArgRepr surfaces
|
||||
> .unresolved for an unresolvable reflection arg ref (issue 0075)" (fail-before with
|
||||
> `orelse .s64` → `.bare`; pass-after → `.unresolved`).
|
||||
|
||||
# 0075 — silent `getRefIRType(...) orelse TypeId.s64` fallback in reflection builtins
|
||||
|
||||
## Symptom
|
||||
|
||||
Reference in New Issue
Block a user