fix tcompiles
This commit is contained in:
parent
dc33638cb2
commit
9cc23118be
3 changed files with 17 additions and 22 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
echo supports(`++`, 34)
|
||||
echo supports(`not`, true)
|
||||
echo supports(`+`, 34)
|
||||
no supports(`++`, 34)
|
||||
ok supports(`not`, true)
|
||||
ok supports(`+`, 34)
|
||||
|
||||
no compiles(4+5.0 * "hallo")
|
||||
|
||||
when compiles(4+5.0 * "hallo"):
|
||||
echo "yes"
|
||||
else:
|
||||
echo "no"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue