Skip to content

Fix Issue 21294: Improve unhelpful error message with duplicate named argument in overload set#22804

Open
shivajigandham wants to merge 6 commits intodlang:masterfrom
shivajigandham:fix-issue-21294
Open

Fix Issue 21294: Improve unhelpful error message with duplicate named argument in overload set#22804
shivajigandham wants to merge 6 commits intodlang:masterfrom
shivajigandham:fix-issue-21294

Conversation

@shivajigandham
Copy link
Copy Markdown

Fixes #21294

Description

When calling an overload set with a duplicate named argument (e.g., fun(a: 1, a: 2)), the compiler previously reported a generic "none of the overloads are callable" error. This happened because the specific error from resolveNamedArgs was being treated as a supplemental error and then masked by the primary resolution failure.

This PR:

  1. Updates checkNamedArgErrorAndReportOverload to check all candidates in an overload set.
  2. If all candidates fail with the same named argument error (e.g., "parameter a assigned twice"), it promotes that error to a primary error.
  3. Modifies resolveFuncCall to respect these primary errors and avoid printing redundant "none of the overloads are callable" messages.

This results in much clearer diagnostics for duplicate named arguments in overloaded functions.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @shivajigandham! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#22804"

@rikkimax
Copy link
Copy Markdown
Contributor

It appears that you may have misunderstood what supplemental messages are.

They are basically additional lines of output.
Formatted slightly differently from non-supplemental messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhelpful error message with duplicate named argument when calling overload set

3 participants