diff options
-rw-r--r-- | compiler/commands.nim | 2 | ||||
-rw-r--r-- | compiler/options.nim | 1 | ||||
-rw-r--r-- | compiler/semcall.nim | 20 | ||||
-rw-r--r-- | doc/advopt.txt | 3 |
4 files changed, 18 insertions, 8 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index b39cc0b72..4346694f8 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -739,6 +739,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "hint": conf.globalOptions = conf.globalOptions + {optStyleHint} of "error": conf.globalOptions = conf.globalOptions + {optStyleError} else: localError(conf, info, errOffHintsError % arg) + of "showallmismatches": + processOnOffSwitchG(conf, {optShowAllMismatches}, arg, pass, info) of "cppcompiletonamespace": if arg.len > 0: conf.cppCustomNamespace = arg diff --git a/compiler/options.nim b/compiler/options.nim index 1280cb59b..5f152ed49 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -74,6 +74,7 @@ type # please make sure we have under 32 options optIdeTerse # idetools: use terse descriptions optNoCppExceptions # use C exception handling even with CPP optExcessiveStackTrace # fully qualified module filenames + optShowAllMismatches # show all overloading resolution candidates optWholeProject # for 'doc2': output any dependency optMixedMode # true if some module triggered C++ codegen optListFullPaths diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 49b344274..c391cb7c9 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -166,20 +166,22 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors): prefer = preferModuleInfo break - when false: - # 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 + # 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 + if optShowAllMismatches notin c.config.globalOptions: for err in errors: if err.firstMismatch > 1: filterOnlyFirst = true break var candidates = "" + var skipped = 0 for err in errors: - when false: - if filterOnlyFirst and err.firstMismatch == 1: continue + if filterOnlyFirst and err.firstMismatch == 1: + inc skipped + continue if err.sym.kind in routineKinds and err.sym.ast != nil: add(candidates, renderTree(err.sym.ast, {renderNoBody, renderNoComments, renderNoPragmas})) @@ -216,7 +218,9 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors): "' is immutable\n") for diag in err.diagnostics: candidates.add(diag & "\n") - + if skipped > 0: + candidates.add($skipped & " other mismatching symbols have been " & + " suppressed; compile with --showAllMismatches:on to see them\n") result = (prefer, candidates) const diff --git a/doc/advopt.txt b/doc/advopt.txt index 252067129..4fabdda9a 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -29,6 +29,9 @@ Advanced options: produce hints or errors for Nim identifiers that do not adhere to Nim's official style guide https://nim-lang.org/docs/nep1.html + --showAllMismatches:on|off + show all mismatching candidates in overloading + resolution --lib:PATH set the system library path --import:PATH add an automatically imported module --include:PATH add an automatically included module |