From 361a2d830aca1959d3dbc15d13bea31f89fcd0e2 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 23 Aug 2018 17:54:04 +0200 Subject: enforce the condition of a 'when' condition to be of type bool; refs #8603 --- compiler/semexprs.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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") -- cgit 1.4.1-2-gfad0