fix: thread optional child type into ?? struct-literal default (issue 0166)

The RHS of a null-coalesce was lowered with no target type, so a bare
struct literal default (x ?? .{ ... }) produced a struct_init with
.ty == .unresolved that panicked in emitStructInit. lowerNullCoalesce
now saves self.target_type, sets it to the optional's resolved child
before lowering nc.rhs, and restores it (leak-free). Verified across
struct/slice/enum/tuple/protocol/nested-optional/generic child types by
3 adversarial reviews.

Regression: examples/optionals/0912-null-coalesce-struct-literal.sx.
Filed adjacent pre-existing bug 0172 (?? on a non-optional lhs panics).
This commit is contained in:
agra
2026-06-22 22:17:01 +03:00
parent 0bc8005b99
commit 2ea25e84ec
7 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
1 2 4
9 3 99
7 3 0