diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-08-27 01:01:03 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-08-27 01:01:03 +0300 |
commit | 9cc23118be5afc701d6eac2f71522aa1f4a327cc (patch) | |
tree | 8f4e88b32d6f09a3b9bcb9c7f1bb44580156d4cb | |
parent | dc33638cb256fa47ab723d991e85b746fc690d59 (diff) | |
download | Nim-9cc23118be5afc701d6eac2f71522aa1f4a327cc.tar.gz |
fix tcompiles
-rw-r--r-- | compiler/semcall.nim | 7 | ||||
-rw-r--r-- | compiler/semexprs.nim | 1 | ||||
-rw-r--r-- | tests/compile/tcompiles.nim | 31 |
3 files changed, 17 insertions, 22 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim index c7f4e4387..8c20d0faa 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -134,9 +134,8 @@ proc resolveOverloads(c: PContext, n, orig: PNode, return elif result.state != csMatch: if nfExprCall in n.flags: - if c.inCompilesContext > 0 or gErrorCounter == 0: - LocalError(n.info, errExprXCannotBeCalled, - renderTree(n, {renderNoComments})) + LocalError(n.info, errExprXCannotBeCalled, + renderTree(n, {renderNoComments})) else: errors = @[] pickBest(f) @@ -217,7 +216,7 @@ proc semOverloadedCall(c: PContext, n, nOrig: PNode, filter: TSymKinds): PNode = var r = resolveOverloads(c, n, nOrig, filter) if r.state == csMatch: result = semResolvedCall(c, n, r) - else: result = errorNode(c, n) + # else: result = errorNode(c, n) proc explicitGenericInstError(n: PNode): PNode = LocalError(n.info, errCannotInstantiateX, renderTree(n)) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index a688efc5b..aedd2364d 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -738,6 +738,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode = nOrig.sons[0] = prc n.flags.incl nfExprCall result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags) + if result == nil: return errorNode(c, n) #result = afterCallActions(c, result, nOrig, flags) fixAbstractType(c, result) analyseIfAddressTakenInCall(c, result) diff --git a/tests/compile/tcompiles.nim b/tests/compile/tcompiles.nim index 1a1d947b1..d0fccdaff 100644 --- a/tests/compile/tcompiles.nim +++ b/tests/compile/tcompiles.nim @@ -1,31 +1,26 @@ -discard """ - output: '''obj has '==': false -int has '==': true -false -true -true -no''' -""" - # test the new 'compiles' feature: template supports(opr, x: expr): bool {.immediate.} = compiles(opr(x)) or compiles(opr(x, x)) +template ok(x: expr): stmt = + static: assert(x) + +template no(x: expr): stmt = + static: assert(not x) + type TObj = object var myObj {.compileTime.}: TObj -echo "obj has '==': ", supports(`==`, myObj) -echo "int has '==': ", supports(`==`, 45) +ok supports(`==`, myObj) +ok supports(`==`, 45) + +no supports(`++`, 34) +ok supports(`not`, true) +ok supports(`+`, 34) -echo supports(`++`, 34) -echo supports(`not`, true) -echo supports(`+`, 34) +no compiles(4+5.0 * "hallo") -when compiles(4+5.0 * "hallo"): - echo "yes" -else: - echo "no" |