mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
enforce the condition of a 'when' condition to be of type bool; refs #8603
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user