From 30621c4a8969ac4b121d04a06315bd4f2089a7c4 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 24 Aug 2018 00:09:08 +0200 Subject: improve error messages by filtering out highly unlikely mismatches --- compiler/semcall.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'compiler/semcall.nim') 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})) -- cgit 1.4.1-2-gfad0