-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue 16165 - Show expected number of function arguments on mismatch #7584
Conversation
|
Thanks for your pull request and interest in making D better, @ntrel! 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 references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#7584" |
|
Thank you very much for doing this work. I think this is VERY IMPORTANT. That being said, I've thought about this and wanted to share my thoughts on how we could improve error messages in the best possible way. I haven't looked at the implementation enough to know whether or not this would be easy, this is just based on what I'd like to see as a developer. I think the first thing we should check is if there is a mismatch in argument count. If so, then it likely means the developer either missed or added an extra argument. In this case, I think the most helpful message would be: Note that in the case there are no type mismatches, this likely means they just forgot the last argument, so the first line of the previous error message alone should suffice. If there is more than 1 type mismatch, then it's probably better to only print the first one because missing or adding an extra argument is likely to propogate "red herring" errors down the line. If the argument count is correct, then we must have one or more type mismatches. In the case of 1 type mismatch, a short error message like this should work well: If there is more than one type mismatch, then a multiline error message would probably be better: In the case of overloads, just seeing the types is often too little information, however, you also don't want to print the full error message for each overload. I think the current method of printing all the candidates is great, simply adding a special character that shows where the type mismatches are would work well here. Also, printing when there is argument count mismatch may be worth the extra characters, i.e. Note that type mismatches are indicated by a |
|
@ntrel are you aware of the CI failures? Though I don't know either what could have introduced them.. |
and color-highlight mis-matches when color=on |
|
I'm not sure if @ntrel is for or against the suggestions I've made. I'll wait to see if/when this PR gets integrated and afterwards probably look into making those changes myself. |
|
@marler8997: Here I'm avoiding changing the signature of Given that, I've added 2 commits to help the user pin-point the failing parameter match, rather than just saying the argument/parameter count. For overloads, one option would be to print the specific error only when |
I don't know why that's happening. |
|
No idea about the auto-tester failures, looks like an issue with 2.068.2. If your OS doesn't use hardening, you can set the host compiler with CircleCi + Semaphore are known - I haven't had time to look into to that though :/
edit: I'm proposing to revert the Phobos PR for now: dlang/phobos#6130 |
|
@ntrel Ok it sounds like my suggestions would require a bigger set of changes. Go ahead with this, any improvement in the current situation is good. If I have time after this PR is merged I might look into this. |
|
Okay looks like we got over almost all failures, though the auto-tester is still complaining: |
66237e5 to
56ab089
Compare
|
@ntrel do you plan on pursuing this? I think it is very important that this gets merged eventually, so will you take it to completion or should someone adopt it? |
|
You could please do a rebase instead? |
|
Are all these commits necessary, would it be better to squash them instead? |
|
@jacob-carlborg f286ceb and 3437c00 are cherry-picked from |
|
ok |
|
@RazvanN7 Anyone is welcome to take this over. I think I've done all I can to try to fix all the checks, but still two remain failing. |
|
FYI the SemaphoreCI failure is related to GDC having issues when building this: |
|
@wilzbach you forgot the ice line in the compiler itself. |
| @@ -1,15 +1,56 @@ | |||
| /* | |||
| TEST_OUTPUT: | |||
| --- | |||
| fail_compilation/fail332.d(14): Error: function `fail332.foo(int _param_0, ...)` is not callable using argument types `()` | |||
| fail_compilation/fail332.d(22): Error: function `fail332.foo(int _param_0, ...)` is not callable using argument types `()` | |||
| fail_compilation/fail332.d(22): missing argument for parameter #1: `int _param_0` | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is _param_0 mentioned sometimes and sometimes it's not, i.e.: https://github.com/dlang/dmd/pull/7584/files#diff-534158a8eaceb0162bf8ef17709be089R33
| fail_compilation/diag8101.d(51): `diag8101.t_2(T1, T2, T3, T4, T5)()` | ||
| fail_compilation/diag8101.d(62): ... (1 more, -v to show) ... | ||
| fail_compilation/diag8101.d(57): Error: function `diag8101.f_0(int)` is not callable using argument types `()` | ||
| fail_compilation/diag8101.d(57): missing argument for parameter #1: `int` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this error message look like with several missing arguments?
704eda6 to
4f772c1
Compare
|
@ntrel this is green. Anything more you want to add? Otherwise please squash. |
|
@thewilsonator That's great, I think this is good to go. I don't have my laptop where I am for the next few days, so it might take me a while to squash commits (unless there's a way to do it in a browser?). |
This finds the first argument that fails to match.
Fix test line numbers, Windows backslash Show which parameter is missing an argument Don't allocate argument count mismatch string when errors gagged Mark getMatchError as private
|
@thewilsonator I've now squashed 4 simple commits into one. |
This is ready now #7554 has been merged.