enforce the condition of a 'when' condition to be of type bool; refs #8603
This commit is contained in:
parent
1546826006
commit
361a2d830a
1 changed files with 1 additions and 1 deletions
|
|
@ -2085,7 +2085,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
|
||||||
typ = commonType(typ, it.sons[1].typ)
|
typ = commonType(typ, it.sons[1].typ)
|
||||||
result = n # when nimvm is not elimited until codegen
|
result = n # when nimvm is not elimited until codegen
|
||||||
else:
|
else:
|
||||||
var e = semConstExpr(c, it.sons[0])
|
let e = forceBool(c, semConstExpr(c, it.sons[0]))
|
||||||
if e.kind != nkIntLit:
|
if e.kind != nkIntLit:
|
||||||
# can happen for cascading errors, assume false
|
# can happen for cascading errors, assume false
|
||||||
# InternalError(n.info, "semWhen")
|
# InternalError(n.info, "semWhen")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue