improve error messages by filtering out highly unlikely mismatches
This commit is contained in:
parent
35e37fd8ec
commit
30621c4a89
1 changed files with 10 additions and 0 deletions
|
|
@ -164,8 +164,18 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
||||||
prefer = preferModuleInfo
|
prefer = preferModuleInfo
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# we pretend procs are attached to the type of the first
|
||||||
|
# argument in order to remove plenty of candidates. This is
|
||||||
|
# comparable to what C# does and C# is doing fine.
|
||||||
|
var filterOnlyFirst = false
|
||||||
|
for err in errors:
|
||||||
|
if err.firstMismatch > 1:
|
||||||
|
filterOnlyFirst = true
|
||||||
|
break
|
||||||
|
|
||||||
var candidates = ""
|
var candidates = ""
|
||||||
for err in errors:
|
for err in errors:
|
||||||
|
if filterOnlyFirst and err.firstMismatch == 1: continue
|
||||||
if err.sym.kind in routineKinds and err.sym.ast != nil:
|
if err.sym.kind in routineKinds and err.sym.ast != nil:
|
||||||
add(candidates, renderTree(err.sym.ast,
|
add(candidates, renderTree(err.sym.ast,
|
||||||
{renderNoBody, renderNoComments, renderNoPragmas}))
|
{renderNoBody, renderNoComments, renderNoPragmas}))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue