diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-08-23 17:54:04 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-08-23 17:54:04 +0200 |
commit | 361a2d830aca1959d3dbc15d13bea31f89fcd0e2 (patch) | |
tree | 506fb0a12574f2e3088e53305492b0f46e314071 | |
parent | 1546826006ca8debf245f712e398813f12bcd7d6 (diff) | |
download | Nim-361a2d830aca1959d3dbc15d13bea31f89fcd0e2.tar.gz |
enforce the condition of a 'when' condition to be of type bool; refs #8603
-rw-r--r-- | compiler/semexprs.nim | 2 |
1 files changed, 1 insertions, 1 deletions
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") |