Skip to content

Fix #issue 23177 - add a diagnostic hint for f() vs f(void)#23218

Open
gulugulubing wants to merge 8 commits into
dlang:masterfrom
gulugulubing:issue23177
Open

Fix #issue 23177 - add a diagnostic hint for f() vs f(void)#23218
gulugulubing wants to merge 8 commits into
dlang:masterfrom
gulugulubing:issue23177

Conversation

@gulugulubing

Copy link
Copy Markdown
Contributor

It is related to #23177: Add a ParamListMismatchHint() in importc.d for the case: parameter is K&R (), argument is a prototyped empty list, and toChars() match.

@dlang-bot

Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @gulugulubing! 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.

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#23218"

Comment thread compiler/src/dmd/importc.d Outdated

@dkorpel dkorpel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too much code just to address the problem in a very specific case. As a simpler solution, perhaps add a new string representation for K&R variadics in hdrgen.d, so that it doesn't print as: void function() but as void function(<K&R variadics>) (there is not syntax for this in D so it doesn't have to compile) . That should clarify the mismatch in all cases.

Comment thread compiler/src/dmd/importc.d Outdated
Comment thread compiler/src/dmd/importc.d Outdated
Comment thread compiler/src/dmd/typesem.d Outdated
@gulugulubing

Copy link
Copy Markdown
Contributor Author

As a simpler solution, perhaps add a new string representation for K&R variadics in hdrgen.d, so that it doesn't print as: void function() but as void function(<K&R variadics>)

Got it. It's nicer.

@gulugulubing gulugulubing requested a review from dkorpel June 5, 2026 17:10
Comment thread compiler/src/dmd/hdrgen.d Outdated

case VarArg.KRvariadic:
// Diagnostic-only spelling; header/.di output keeps plain `()`.
if (!pl.length && !hgs.hdrgen)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why !pl.length?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed. And I added a test with one parameter.

@gulugulubing gulugulubing requested a review from dkorpel June 5, 2026 22:02
Comment thread compiler/test/fail_compilation/diag23177.d Outdated
Comment thread compiler/src/dmd/hdrgen.d Outdated
case VarArg.KRvariadic:
// Diagnostic-only spelling; header/.di output keeps plain `()`.
if (!hgs.hdrgen)
buf.put("<K&R variadics>");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option: "<unspecified>".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given C23 allows ... without a named parameter (see #23232), perhaps we can just use ... for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the help.

@gulugulubing gulugulubing requested a review from dkorpel June 8, 2026 21:46
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.

5 participants