fix(ir): poison type-fn binder on failed value-param bind (0083)
A failed value-param bind on a type-returning function (e.g.
`MakeC :: ($K: Count, $T: Type) -> Type { return [K]T; }` with
`a : MakeC(5_000_000_000, s64)`) emitted its correct range diagnostic
but then `instantiateTypeFunction` returned `null`, so
`resolveParameterizedWithBindings` fell through to an empty-struct
placeholder named after the function. The binding `a` got that
placeholder type, so a later `a.len` cascaded a bogus second error
`field 'len' not found on type 'MakeC'`.
The struct binder (`instantiateGenericStruct`) already returns
`.unresolved` here; the type-fn binder now matches it — a failed
value-param bind poisons to `.unresolved` instead of `null`, so the
caller propagates the diagnosed poison and the existing
`emitFieldError` suppression yields one clean diagnostic. Covers
every type-fn value-param failure mode: overflow via an aliased
constraint, a non-const arg, and an unknown type arg.
Regression: examples/1137-diagnostics-value-param-type-fn-no-cascade.sx
This commit is contained in:
@@ -195,6 +195,23 @@
|
||||
> u32 + s8 overflow), `examples/1136-diagnostics-array-dim-nonconst-direct-no-crash.sx`
|
||||
> (direct non-const dim halts cleanly, no fabrication / panic); the cascade
|
||||
> cleanup also tightened `examples/1502`/`1503` to one diagnostic each.
|
||||
>
|
||||
> **Final convergence — type-fn binder parity (attempt 10).** One last cell of
|
||||
> the count surface still diverged from the struct binder. A FAILED value-param
|
||||
> bind on a type-RETURNING FUNCTION (`MakeC :: ($K: Count, $T: Type) -> Type
|
||||
> { return [K]T; }`; `a : MakeC(5_000_000_000, s64)`) emitted its correct range
|
||||
> diagnostic, but `instantiateTypeFunction` then returned `null`, so
|
||||
> `resolveParameterizedWithBindings` fell through to the empty-struct *placeholder*
|
||||
> named `MakeC`. The binding `a` got that placeholder type, so a downstream
|
||||
> `a.len` cascaded a bogus second error `field 'len' not found on type 'MakeC'`.
|
||||
> The struct binder (`instantiateGenericStruct`) already returned `.unresolved`
|
||||
> here; the type-fn binder now matches it — the failed value-param bind poisons to
|
||||
> `.unresolved` instead of `null`, so the caller propagates the diagnosed poison
|
||||
> and the existing `emitFieldError` suppression yields ONE clean diagnostic. Covers
|
||||
> every type-fn value-param failure mode (overflow via aliased constraint,
|
||||
> non-const arg, unknown type arg). Files: `src/ir/lower.zig` (one line in
|
||||
> `instantiateTypeFunction`). Regression:
|
||||
> `examples/1137-diagnostics-value-param-type-fn-no-cascade.sx`.
|
||||
|
||||
## Symptom
|
||||
A fixed array whose dimension is a module-global integer constant (`N :: 16;
|
||||
|
||||
Reference in New Issue
Block a user