mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-16 22:11:18 +00:00
improve the error messages when overloaded '.' operators are involved
This commit is contained in:
@@ -179,7 +179,7 @@ proc notFoundError*(c: PContext, n: PNode, errors: CandidateErrors) =
|
||||
add(result, ')')
|
||||
if candidates != "":
|
||||
add(result, "\n" & msgKindToString(errButExpected) & "\n" & candidates)
|
||||
localError(n.info, errGenerated, result)
|
||||
localError(n.info, errGenerated, result & "\nexpression: " & $n)
|
||||
|
||||
proc bracketNotFoundError(c: PContext; n: PNode) =
|
||||
var errors: CandidateErrors = @[]
|
||||
@@ -238,6 +238,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
||||
|
||||
# leave the op head symbol empty,
|
||||
# we are going to try multiple variants
|
||||
errors = nil
|
||||
n.sons[0..1] = [nil, n[1], f]
|
||||
orig.sons[0..1] = [nil, orig[1], f]
|
||||
|
||||
@@ -254,6 +255,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
||||
tryOp "."
|
||||
|
||||
elif nfDotSetter in n.flags and f.kind == nkIdent and n.len == 3:
|
||||
errors = nil
|
||||
# we need to strip away the trailing '=' here:
|
||||
let calleeName = newIdentNode(getIdent(f.ident.s[0..f.ident.s.len-2]), n.info)
|
||||
let callOp = newIdentNode(getIdent".=", n.info)
|
||||
|
||||
Reference in New Issue
Block a user