-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Improve error supplemental #16755
base: master
Are you sure you want to change the base?
Improve error supplemental #16755
Conversation
Thanks for your pull request, @ljmf00! 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#16755" |
341e7d9
to
774d8ce
Compare
774d8ce
to
b84323a
Compare
Can we agree on a format first before I change every expcted failure test messages? Do you think these messages are ok? CC @dkorpel @JohanEngelen |
--- | ||
*/ | ||
|
||
#line 100 |
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.
Suggestion: we could make a pre pass of the testsuite where it instruments the code to add correct line numbers, so the initial comment doesn't affect it,
or:
Start enforcing a #line
directive to most of the tests.
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.
I want to do away with #line
directives since they make it hard to locate the line the error belongs to. Instead, I'm working on implementing this: #14515
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.
See my comment on #14515 .
I like the recent addition of supplemental error messages pointing to the declaration site of types / functions related to the error, so adding it to templates looks good to me. If I understand correctly, it just shows the first template declaration, not the 'closest' matching template, but that's a future enhancement. I don't understand the "instantiated from here: |
The first one does, but the Maybe an alternative. Instead of this:
We could do this, perhaps (notice the difference on line numbers):
Maybe rewrite the main error message but I'm out of ideas other than swapping it:
|
It should show up on the multi candidate error message. Maybe I'm missing what you meant. Can you elaborate? |
Ping @dkorpel |
I mean when there's multiple template overloads, which candidate(s) does it print? My impression was it just picks one, but I didn't study it closely yet. |
I don't see any tests that use |
See this test example:
|
There's still just one template overload there. What I'm wondering about is this: void foo(int n : 0) {}
void foo(int n : 1) {}
void foo(int n : 2) {}
alias foo3 = foo!3; But I noticed that it already prints all candidates in that case: onlineapp.d(6): Error: template instance `foo!3` does not match any template declaration
onlineapp.d(6): Candidates are:
onlineapp.d(2): foo(int n : 0)()
onlineapp.d(3): foo(int n : 1)()
onlineapp.d(4): foo(int n : 2)() The error this PR improves is when it already found a template it must match, but there's an error in the template body. If that's correct, then I think the error should simply say: "Template declared here:", because "Candidate match: " suggests that it prints only one of multiple candidates. |
ok, makes sense, will change to |
No description provided.