enforce the condition of a 'when' condition to be of type bool; refs #8603

This commit is contained in:
Andreas Rumpf
2018-08-23 17:54:04 +02:00
parent 1546826006
commit 361a2d830a

View File

@@ -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")