fix tcompiles
This commit is contained in:
parent
dc33638cb2
commit
9cc23118be
3 changed files with 17 additions and 22 deletions
|
|
@ -134,7 +134,6 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
||||||
return
|
return
|
||||||
elif result.state != csMatch:
|
elif result.state != csMatch:
|
||||||
if nfExprCall in n.flags:
|
if nfExprCall in n.flags:
|
||||||
if c.inCompilesContext > 0 or gErrorCounter == 0:
|
|
||||||
LocalError(n.info, errExprXCannotBeCalled,
|
LocalError(n.info, errExprXCannotBeCalled,
|
||||||
renderTree(n, {renderNoComments}))
|
renderTree(n, {renderNoComments}))
|
||||||
else:
|
else:
|
||||||
|
|
@ -217,7 +216,7 @@ proc semOverloadedCall(c: PContext, n, nOrig: PNode,
|
||||||
filter: TSymKinds): PNode =
|
filter: TSymKinds): PNode =
|
||||||
var r = resolveOverloads(c, n, nOrig, filter)
|
var r = resolveOverloads(c, n, nOrig, filter)
|
||||||
if r.state == csMatch: result = semResolvedCall(c, n, r)
|
if r.state == csMatch: result = semResolvedCall(c, n, r)
|
||||||
else: result = errorNode(c, n)
|
# else: result = errorNode(c, n)
|
||||||
|
|
||||||
proc explicitGenericInstError(n: PNode): PNode =
|
proc explicitGenericInstError(n: PNode): PNode =
|
||||||
LocalError(n.info, errCannotInstantiateX, renderTree(n))
|
LocalError(n.info, errCannotInstantiateX, renderTree(n))
|
||||||
|
|
|
||||||
|
|
@ -738,6 +738,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
nOrig.sons[0] = prc
|
nOrig.sons[0] = prc
|
||||||
n.flags.incl nfExprCall
|
n.flags.incl nfExprCall
|
||||||
result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
|
result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
|
||||||
|
if result == nil: return errorNode(c, n)
|
||||||
#result = afterCallActions(c, result, nOrig, flags)
|
#result = afterCallActions(c, result, nOrig, flags)
|
||||||
fixAbstractType(c, result)
|
fixAbstractType(c, result)
|
||||||
analyseIfAddressTakenInCall(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:
|
# test the new 'compiles' feature:
|
||||||
|
|
||||||
template supports(opr, x: expr): bool {.immediate.} =
|
template supports(opr, x: expr): bool {.immediate.} =
|
||||||
compiles(opr(x)) or compiles(opr(x, x))
|
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
|
type
|
||||||
TObj = object
|
TObj = object
|
||||||
|
|
||||||
var
|
var
|
||||||
myObj {.compileTime.}: TObj
|
myObj {.compileTime.}: TObj
|
||||||
|
|
||||||
echo "obj has '==': ", supports(`==`, myObj)
|
ok supports(`==`, myObj)
|
||||||
echo "int has '==': ", supports(`==`, 45)
|
ok supports(`==`, 45)
|
||||||
|
|
||||||
echo supports(`++`, 34)
|
no supports(`++`, 34)
|
||||||
echo supports(`not`, true)
|
ok supports(`not`, true)
|
||||||
echo supports(`+`, 34)
|
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