summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-10-29 19:52:02 +0100
committerAraq <rumpf_a@web.de>2018-10-30 11:28:45 +0100
commitf6def4286c12a2c4a68a3d9e04d562359aeb160b (patch)
tree3c1b4da204dd575c52299d15dce46068d6cfbaf7 /compiler
parentdf68c2da49f99cea5824623d2512b5be27a9a116 (diff)
downloadNim-f6def4286c12a2c4a68a3d9e04d562359aeb160b.tar.gz
fixes #8603
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semgnrc.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index e1a8390e1..a0044a0af 100644
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -322,7 +322,14 @@ proc semGenericStmt(c: PContext, n: PNode,
       n.sons[i] = semGenericStmtScope(c, n.sons[i], flags, ctx)
   of nkWhenStmt:
     for i in countup(0, sonsLen(n)-1):
-      n.sons[i] = semGenericStmt(c, n.sons[i], flags+{withinMixin}, ctx)
+      # bug #8603: conditions of 'when' statements are not
+      # in a 'mixin' context:
+      let it = n[i]
+      if it.kind in {nkElifExpr, nkElifBranch}:
+        n.sons[i].sons[0] = semGenericStmt(c, it[0], flags, ctx)
+        n.sons[i].sons[1] = semGenericStmt(c, it[1], flags+{withinMixin}, ctx)
+      else:
+        n.sons[i] = semGenericStmt(c, it, flags+{withinMixin}, ctx)
   of nkWhileStmt:
     openScope(c)
     for i in countup(0, sonsLen(n)-1):