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
commit bdeaee4a33
4 changed files with 17 additions and 14 deletions

View file

@ -354,6 +354,7 @@ type
nfTransf, # node has been transformed nfTransf, # node has been transformed
nfSem # node has been checked for semantics nfSem # node has been checked for semantics
nfDelegate # the call can use a delegator nfDelegate # the call can use a delegator
nfExprCall # this is an attempt to call a regular expression
TNodeFlags* = set[TNodeFlag] TNodeFlags* = set[TNodeFlag]
TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 23) 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) pickBest(callOp)
if result.state == csEmpty: if result.state == csEmpty:
errors = @[] if nfExprCall in n.flags:
pickBest(f) if c.inCompilesContext > 0 or gErrorCounter == 0:
NotFoundError(c, n, errors) LocalError(n.info, errExprXCannotBeCalled,
renderTree(n, {renderNoComments}))
else:
errors = @[]
pickBest(f)
NotFoundError(c, n, errors)
return return
if alt.state == csMatch and cmpCandidates(result, alt) == 0 and 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, # 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: # the old ``prc`` (which is likely an nkIdent) has to be restored:
if result == nil: 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 n.sons[0] = prc
nOrig.sons[0] = prc nOrig.sons[0] = prc
n.flags.incl nfExprCall
result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags) 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) #result = afterCallActions(c, result, nOrig, flags)
fixAbstractType(c, result) fixAbstractType(c, result)
analyseIfAddressTakenInCall(c, result) analyseIfAddressTakenInCall(c, result)

View file

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