fixes #25945; cannot map the empty seq type to a C type (#25954)

fixes #25945

When `@[]` appears inside a nested `if` expression that also contains
statements, the AST wraps it in `nkStmtListExpr` nodes. The empty
container's `tyEmpty` element type was never resolved to a concrete
type, causing the C codegen to ICE with "cannot map the empty seq type
to a C type".

Walk through nested statement-list/block expressions in
`fitNodePostMatch` to find the innermost value node and propagate the
formal type to empty containers.
This commit is contained in:
ringabout
2026-07-02 18:02:16 +08:00
committed by GitHub
parent 3b9100178e
commit a0e44d7aca
2 changed files with 24 additions and 0 deletions

View File

@@ -75,3 +75,15 @@ block: # importc type inheritance
doAssert(cast[cint](b) == 123)
var c = foo(b)
doAssert(cast[cint](c) == 123)
block: # bug #25945
var stateRefund = 0
let authCode =
if true:
if false:
stateRefund += 0
@[]
else:
@([1.byte])
discard (if true: (discard; @[]) else: @[0])