mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-22 00:41:28 +00:00
@@ -624,7 +624,11 @@ proc transformCase(c: PTransf, n: PNode): PTransNode =
|
||||
case it.kind
|
||||
of nkElifBranch:
|
||||
if ifs.PNode == nil:
|
||||
ifs = newTransNode(nkIfStmt, it.info, 0)
|
||||
# Generate the right node depending on whether `n` is used as a stmt or
|
||||
# as an expr
|
||||
let kind = if n.typ != nil: nkIfExpr else: nkIfStmt
|
||||
ifs = newTransNode(kind, it.info, 0)
|
||||
ifs.PNode.typ = n.typ
|
||||
ifs.add(e)
|
||||
of nkElse:
|
||||
if ifs.PNode == nil: result.add(e)
|
||||
|
||||
7
tests/js/t7534.nim
Normal file
7
tests/js/t7534.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
proc f(x: int): int =
|
||||
result = case x
|
||||
of 1: 2
|
||||
elif x == 2: 3
|
||||
else: 1
|
||||
|
||||
doAssert 2 == f(f(f(f(1))))
|
||||
Reference in New Issue
Block a user