Skip to content

Commit

Permalink
enforce the condition of a 'when' condition to be of type bool; refs #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Aug 23, 2018
1 parent 1546826 commit 361a2d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 361a2d8

Please sign in to comment.