mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-13 12:40:32 +00:00
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:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user