issues/0066: RESOLVED — match-value arms lowered against result type

A value-position match's arms are now lowered with `target_type` set to
the merge's `result_type`, so positive and negated integer literals pick
the same width. Fixes the `PHI node operands are not the same type as the
result` failure for `if n == { case 0: 100; else: -1; }`-style returns.

Regression: examples/0043-basic-match-value-mixed-width.sx.
Gates: zig build, zig build test, run_examples.sh -> 345 passed.
This commit is contained in:
agra
2026-06-02 09:35:41 +03:00
parent 92dba9078c
commit 80abaf1e7d
6 changed files with 47 additions and 0 deletions

View File

@@ -1,5 +1,11 @@
# 0066 — match-as-value with a negated-literal arm builds a mismatched phi
> **RESOLVED.** `lowerMatch`'s value path (`has_value_merge`) now lowers each
> arm body with `target_type = result_type`, so literals and negated literals in
> the arms pick the merge's width instead of leaking a narrower one. The phi
> operands are uniform; `coerceToType` still runs afterward as a backstop.
> Regression: `examples/0043-basic-match-value-mixed-width.sx`.
## Symptom
A value-position `match` (the `if subject == { case ... }` sugar) returning a