diff options
author | cooldome <cdome@bk.ru> | 2020-04-25 18:59:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 19:59:56 +0200 |
commit | 13fa338ada7fcd8f7f33365ffd2000c79a4607fe (patch) | |
tree | 51dc65763798358f850172003c7e8a1e0469b43a | |
parent | f3eeb3f921edb1d70e751eb6262e3e87f9b1e806 (diff) | |
download | Nim-13fa338ada7fcd8f7f33365ffd2000c79a4607fe.tar.gz |
implement (#14114)
Co-authored-by: cooldome <ariabushenko@bk.ru>
-rw-r--r-- | compiler/sem.nim | 11 | ||||
-rw-r--r-- | tests/objects/twhen1.nim | 6 |
2 files changed, 9 insertions, 8 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim index 1ced234f5..aa5928c18 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -481,15 +481,10 @@ proc forceBool(c: PContext, n: PNode): PNode = if result == nil: result = n proc semConstBoolExpr(c: PContext, n: PNode): PNode = - let nn = semExprWithType(c, n) - result = fitNode(c, getSysType(c.graph, n.info, tyBool), nn, nn.info) - if result == nil: - localError(c.config, n.info, errConstExprExpected) - return nn - result = getConstExpr(c.module, result, c.graph) - if result == nil: + result = forceBool(c, semConstExpr(c, n)) + if result.kind != nkIntLit: localError(c.config, n.info, errConstExprExpected) - result = nn + proc semGenericStmt(c: PContext, n: PNode): PNode proc semConceptBody(c: PContext, n: PNode): PNode diff --git a/tests/objects/twhen1.nim b/tests/objects/twhen1.nim index 2301d255a..5b8eea3f4 100644 --- a/tests/objects/twhen1.nim +++ b/tests/objects/twhen1.nim @@ -49,3 +49,9 @@ block: block: var x: Foo4[0] + +type + MyObject = object + x: int + when (NimMajor, NimMinor) >= (1, 1): + y: int |