summary refs log tree commit diff stats
path: root/compiler/semcall.nim
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-09-09 10:50:45 +0300
committerGitHub <noreply@github.com>2024-09-09 09:50:45 +0200
commitf223f016f35af0e32252560ad650c04a81a102ee (patch)
tree67bca40e1688301aeb3bae1e22555b5fffba78ff /compiler/semcall.nim
parent7de4ace94908f515a98fbe6f3a4a022b6fa9e3f8 (diff)
downloadNim-f223f016f35af0e32252560ad650c04a81a102ee.tar.gz
show symchoices as ambiguous in overload type mismatches (#24077)
fixes #23397

All ambiguous symbols generate symchoices for call arguments since
#23123. So, if a type mismatch receives a symchoice node for an
argument, we now treat it as an ambiguous identifier and list the
ambiguous symbols in the error message.
Diffstat (limited to 'compiler/semcall.nim')
-rw-r--r--compiler/semcall.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 06dd09b69..b81bc2a63 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -285,6 +285,8 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
           candidates.add "\n"
         of kTypeMismatch:
           doAssert nArg != nil
+          if nArg.kind in nkSymChoices:
+            candidates.add ambiguousIdentifierMsg(nArg, indent = 2)
           let wanted = err.firstMismatch.formal.typ
           doAssert err.firstMismatch.formal != nil
           doAssert wanted != nil
@@ -317,6 +319,9 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
           candidates.add renderTree(arg)
           candidates.add "' of type: "
           candidates.addTypeDeclVerboseMaybe(c.config, got)
+          if nArg.kind in nkSymChoices:
+            candidates.add "\n"
+            candidates.add ambiguousIdentifierMsg(nArg, indent = 2)
           if got != nil and got.kind == tyProc and wanted.kind == tyProc:
             # These are proc mismatches so,
             # add the extra explict detail of the mismatch
@@ -370,6 +375,9 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
             candidates.add "' is of type: "
             let got = arg.typ
             candidates.addTypeDeclVerboseMaybe(c.config, got)
+            if arg.kind in nkSymChoices:
+              candidates.add "\n"
+              candidates.add ambiguousIdentifierMsg(arg, indent = 2)
             doAssert wanted != nil
             if got != nil:
               if got.kind == tyProc and wanted.kind == tyProc: