dmd
dmd copied to clipboard
Store location of function argument that doesn't match to display `^` at the right index when using `-verrors=context`
This is an improvement over my previous draft: https://github.com/dlang/dmd/pull/15510
Turns out the functionality was already there through: -verrors=context, however, it didn't display the ^ at the right index, making it not useful
Example:
void test(int a, int b, string c, float d) {}
void testme()
{
test(1, 1, 1, 1.0);
}
Before:
x\x\app.d(53): Error: function `app.test(int a, int b, string c, float d)` is not callable using argument types `(int, int, int, double)`
test(1, 1, 1, 1.0);
^
x\x\app.d(53): cannot pass argument `1` of type `int` to parameter `string c`
After:
x\x\app.d(53): Error: function `app.test(int a, int b, string c, float d)` is not callable using argument types `(int, int, int, double)`
test(1, 1, 1, 1.0);
^
x\x\app.d(53): cannot pass argument `1` of type `int` to parameter `string c`
This is better UX for debug messages, i'd personally make -verrors=context the default, it's very good
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#15524"
Is there a way to display multiple lines?
Eg:
void test(int a, int b, string c, float d) {}
void testme()
{
test(1, 1,
1, 1.0);
}
x\x\app.d(54): Error: function `app.test(int a, int b, string c, float d)` is not callable using argument types `(int, int, int, double)`
1, 1.0);
^
x\x\app.d(54): cannot pass argument `1` of type `int` to parameter `string c`
It still is pretty useful, but i'd personally prefer if it could display the whole function, to get a better context, maybe i could add a new error function that accept 2 Locs? (begin and end)
maybe i could add a new
errorfunction that accept 2 Locs? (begin and end)
I'd start by getting the correct location working and perhaps do this in a next PR.
Does anyone know why every checks failed? This PR shouldn't affect the tests..
There's a segfault when compiling Phobos.
Also don't forget to add argLoc to the ddoc comment of callMatch
Thanks! I sent a commit with the requested changes
It's green now, so it only still needs a test. You can probably just add REQUIRED_ARGS: -vcolumns or -verrors=context to an existing test for this error and run with AUTO_UPDATE=1. Do you want help with it?
@ryuukk This PR requires a rebase and a test and we are good to go.