summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-08-23 17:54:04 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-08-23 17:54:04 +0200
commit361a2d830aca1959d3dbc15d13bea31f89fcd0e2 (patch)
tree506fb0a12574f2e3088e53305492b0f46e314071 /compiler
parent1546826006ca8debf245f712e398813f12bcd7d6 (diff)
downloadNim-361a2d830aca1959d3dbc15d13bea31f89fcd0e2.tar.gz
enforce the condition of a 'when' condition to be of type bool; refs #8603
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 5a8c76216..5ff692fd5 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -2085,7 +2085,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
           typ = commonType(typ, it.sons[1].typ)
         result = n # when nimvm is not elimited until codegen
       else:
-        var e = semConstExpr(c, it.sons[0])
+        let e = forceBool(c, semConstExpr(c, it.sons[0]))
         if e.kind != nkIntLit:
           # can happen for cascading errors, assume false
           # InternalError(n.info, "semWhen")