proper discrimination between csEmpty and csNoMatch

fixes twrongtupleaccess and topaque
This commit is contained in:
Zahary Karadjov 2013-08-27 00:08:47 +03:00
commit dc33638cb2
2 changed files with 9 additions and 6 deletions

View file

@ -50,6 +50,7 @@ proc
if sym == nil: return
initCandidate(best, sym, initialBinding, symScope)
initCandidate(alt, sym, initialBinding, symScope)
best.state = csNoMatch
while sym != nil:
if sym.kind in filter:
@ -115,7 +116,8 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
pickBest(f)
if result.state == csEmpty:
let overloadsState = result.state
if overloadsState != csMatch:
if nfDelegate in n.flags:
InternalAssert f.kind == nkIdent
let calleeName = newStrNode(nkStrLit, f.ident.s)
@ -127,7 +129,10 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
pickBest(callOp)
if result.state == csEmpty:
if overloadsState == csEmpty and result.state == csEmpty:
LocalError(n.info, errUndeclaredIdentifier, considerAcc(f).s)
return
elif result.state != csMatch:
if nfExprCall in n.flags:
if c.inCompilesContext > 0 or gErrorCounter == 0:
LocalError(n.info, errExprXCannotBeCalled,

View file

@ -1,12 +1,10 @@
discard """
file: "twrongtupleaccess.nim"
line: 9
errormsg: "undeclared field: \'setBLAH\'"
errormsg: "undeclared identifier: \'setBLAH\'"
"""
# Bugfix
var v = (5.0, 10.0)
v.setBLAH(10)