summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2018-09-07 21:07:06 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-09-07 21:07:06 +0200
commit91b37311d9974ae30745946a52c9a971da1616f4 (patch)
tree705c74fa395ca8e538bd906ca56e3fac08749231 /compiler
parenteae3c305a775efc2d04495199704957964f3a644 (diff)
downloadNim-91b37311d9974ae30745946a52c9a971da1616f4.tar.gz
Fix AST generation for case statements (#8908)
Fixes #7534
Diffstat (limited to 'compiler')
-rw-r--r--compiler/transf.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 84297aa6a..347df3e49 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -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)