dmd
dmd copied to clipboard
Improve error message for when we pass wrong arguments to a function
I think it looks better!
Thanks for your pull request and interest in making D better, @ryuukk! 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:
andReturns:
)
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#13366"
You need to change the tests that are making this fail accordingly.
i'll look into it, thanks
- Can we really not have one error == one line here?
It wasn't really readable before as a one line
- Avoid mixing tabs and spaces.
I'll fix that
- Do we use
%*s
as a format specifier in other errors? (Meaning, has it been vetted as a portable format to use).
I have no idea..
You need to change the tests that are making this fail accordingly.
i'll look into it, thanks
You can use AUTO_UPDATE=1 ./run.d fail
, see:
https://github.com/dlang/dmd/tree/master/test#quick-guide
- Can we really not have one error == one line here?
It wasn't really readable before as a one line
I mean, you can break up an error into multiple lines using errorSupplemental for subsequent messages.
Awesome that you're looking into improving diagnostic!
Could we somehow utilize alignment to make it easier to spot which parameter (index) that is fed the wrong parameter?
I have another request which might belong in a separate PR, namely:
The code snippet
void f(T)(int x) {}
unittest { f(42); }
currently erroring as
template `missing_template_param.f` cannot deduce function from argument types `!()(int)`
Candidate is: `f(T)(int x)`
could also include a errorSupplemental
like
Candidate `f(T)(int x)` is missing a/its/its (single)/(the first) template parameter `T`
.
You need to change the tests that are making this fail accordingly.
i'll look into it, thanks
You can use
AUTO_UPDATE=1 ./run.d fail
, see: https://github.com/dlang/dmd/tree/master/test#quick-guide
thanks!
- Can we really not have one error == one line here?
It wasn't really readable before as a one line
I mean, you can break up an error into multiple lines using errorSupplemental for subsequent messages.
i will do that!
@nordlow
that was initially the goal, to put arrows to display wich one is the problem, or maybe put some color, but i'm not familiar with the code base and i got distracted by my wasm project, that's something definitely worth trying, i will try to find some time and finish this little side project of mine!
@ryuukk any progress on this?
@RazvanN7 i am still busy working on my WASM project, also some people raised some interesting point on IRC that i need to take into consideration
So i want to improve it further
%*s
%*s is specified in c89. It is not used as such elsewhere in dmd, but %.*s is used; so the feature is still required.