fix tnoop

This commit requires further investigation.

Fixing semExpr(nkCall) once and for all to work with sym-choices and to
allow overloading with immediate templates and macros will probably set
this straight too.
This commit is contained in:
Zahary Karadjov
2013-08-26 23:43:39 +03:00
parent 28d9398de7
commit bdeaee4a33
4 changed files with 17 additions and 14 deletions

View File

@@ -354,6 +354,7 @@ type
nfTransf, # node has been transformed
nfSem # node has been checked for semantics
nfDelegate # the call can use a delegator
nfExprCall # this is an attempt to call a regular expression
TNodeFlags* = set[TNodeFlag]
TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 23)

View File

@@ -128,9 +128,14 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
pickBest(callOp)
if result.state == csEmpty:
errors = @[]
pickBest(f)
NotFoundError(c, n, errors)
if nfExprCall in n.flags:
if c.inCompilesContext > 0 or gErrorCounter == 0:
LocalError(n.info, errExprXCannotBeCalled,
renderTree(n, {renderNoComments}))
else:
errors = @[]
pickBest(f)
NotFoundError(c, n, errors)
return
if alt.state == csMatch and cmpCandidates(result, alt) == 0 and

View File

@@ -732,14 +732,12 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
# Now that nkSym does not imply an iteration over the proc/iterator space,
# the old ``prc`` (which is likely an nkIdent) has to be restored:
if result == nil:
# XXX: hmm, what kind of symbols will end up here?
# do we really need to try the overload resolution?
n.sons[0] = prc
nOrig.sons[0] = prc
n.flags.incl nfExprCall
result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
if result == nil:
if c.inCompilesContext > 0 or gErrorCounter == 0:
LocalError(n.info, errExprXCannotBeCalled,
renderTree(n, {renderNoComments}))
return errorNode(c, n)
#result = afterCallActions(c, result, nOrig, flags)
fixAbstractType(c, result)
analyseIfAddressTakenInCall(c, result)

View File

@@ -3,11 +3,10 @@ discard """
line: 11
errormsg: "expression \'a()\' cannot be called"
"""
# Tests the new check in the semantic pass
var
a: int
a() #ERROR_MSG expression 'a()' cannot be called
# Tests the new check in the semantic pass
var
a: int
a() #ERROR_MSG expression 'a()' cannot be called