diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-08-24 00:09:08 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-08-24 00:09:08 +0200 |
commit | 30621c4a8969ac4b121d04a06315bd4f2089a7c4 (patch) | |
tree | 737f7f4f96dd92e12f24a169442829c29b52d2a7 /compiler/semcall.nim | |
parent | 35e37fd8ec721f8588b88fd72c16e36916573908 (diff) | |
download | Nim-30621c4a8969ac4b121d04a06315bd4f2089a7c4.tar.gz |
improve error messages by filtering out highly unlikely mismatches
Diffstat (limited to 'compiler/semcall.nim')
-rw-r--r-- | compiler/semcall.nim | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim index dc71f2567..980cfb691 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -164,8 +164,18 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors): prefer = preferModuleInfo 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 = "" for err in errors: + if filterOnlyFirst and err.firstMismatch == 1: continue if err.sym.kind in routineKinds and err.sym.ast != nil: add(candidates, renderTree(err.sym.ast, {renderNoBody, renderNoComments, renderNoPragmas})) |