Fix #issue 23177 - add a diagnostic hint for f() vs f(void)#23218
Fix #issue 23177 - add a diagnostic hint for f() vs f(void)#23218gulugulubing wants to merge 8 commits into
Conversation
|
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 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 referencesYour 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 locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#23218" |
dkorpel
left a comment
There was a problem hiding this comment.
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.
Got it. It's nicer. |
|
|
||
| case VarArg.KRvariadic: | ||
| // Diagnostic-only spelling; header/.di output keeps plain `()`. | ||
| if (!pl.length && !hgs.hdrgen) |
There was a problem hiding this comment.
Should be removed. And I added a test with one parameter.
| case VarArg.KRvariadic: | ||
| // Diagnostic-only spelling; header/.di output keeps plain `()`. | ||
| if (!hgs.hdrgen) | ||
| buf.put("<K&R variadics>"); |
There was a problem hiding this comment.
Another option: "<unspecified>".
There was a problem hiding this comment.
Given C23 allows ... without a named parameter (see #23232), perhaps we can just use ... for this.
There was a problem hiding this comment.
Thanks for the help.
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.