From 13fa338ada7fcd8f7f33365ffd2000c79a4607fe Mon Sep 17 00:00:00 2001 From: cooldome Date: Sat, 25 Apr 2020 18:59:56 +0100 Subject: [PATCH] implement (#14114) Co-authored-by: cooldome --- compiler/sem.nim | 11 +++-------- tests/objects/twhen1.nim | 6 ++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/sem.nim b/compiler/sem.nim index 1ced234f57..aa5928c183 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: + result = forceBool(c, semConstExpr(c, n)) + if result.kind != nkIntLit: localError(c.config, n.info, errConstExprExpected) - return nn - result = getConstExpr(c.module, result, c.graph) - if result == nil: - 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 2301d255a8..5b8eea3f46 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