fix(0118): cast accepts compound type args; compound type literals are first-class Type values

This commit is contained in:
agra
2026-06-11 14:09:22 +03:00
parent c229f697bd
commit 03dc10bba3
7 changed files with 77 additions and 17 deletions

View File

@@ -1,5 +1,20 @@
# 0118 — `cast(<compound type>) expr` dies with "unresolved 'unknown_expr'"
> **RESOLVED** (2026-06-11, same session, Agra-authorized in-session fix).
> Two-part root cause: (1) `lowerCall` lowers args BEFORE the cast handler,
> and compound type literals had NO expression-position lowering — they hit
> `lowerExpr`'s catch-all `unknown_expr` error. Fixed by giving the six
> compound type-expr shapes (`*T`, `[*]T`, `[]T`, `?T`, `[N]T`, fn types) a
> first-class `const_type` lowering arm in `src/ir/lower/expr.zig`,
> mirroring named types (`t : Type = *s64;` now works like `t : Type =
> f64;`). (2) The cast handler's private static-type gate only accepted
> bare names — replaced with the canonical `isStaticTypeArg`
> (`src/ir/lower/call.zig`), so static compound casts route through
> `coerceExplicit` while the runtime-`Type`-variable form (`cast(type) val`
> in category arms) still falls through to runtime dispatch. Regression
> test: examples/0182-types-cast-compound-types.sx (all compound cast
> forms + the first-class Type value). Suite 579/579.
## Symptom
`cast(T) expr` with a COMPOUND static type argument (`*s64`, `[]u8`, `?s32`,