From f6def4286c12a2c4a68a3d9e04d562359aeb160b Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 29 Oct 2018 19:52:02 +0100 Subject: fixes #8603 --- compiler/semgnrc.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'compiler') 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): -- cgit 1.4.1-2-gfad0