Skip to content
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 message for when we pass wrong arguments to a function #13366

Closed
wants to merge 1 commit into from

Conversation

ryuukk
Copy link
Contributor

@ryuukk ryuukk commented Nov 28, 2021

I think it looks better!

Code_UCCb5oZ3kx

Code_d9qARJAbdE

@dlang-bot
Copy link
Contributor

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: and Returns:)

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"

Copy link
Member

@ljmf00 ljmf00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to change the tests that are making this fail accordingly.

Copy link
Member

@ibuclaw ibuclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can we really not have one error == one line here?
  2. Avoid mixing tabs and spaces.
  3. Do we use %*s as a format specifier in other errors? (Meaning, has it been vetted as a portable format to use).

Comment on lines +3102 to +3103
fd.kind(), fdPC, parametersTypeToChars(tf.parameterList),
tf.modToChars(), pIndex, cast(const(char)*) "", fargsBuf.peekChars());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you prepended a space by mistake in both lines

@ryuukk
Copy link
Contributor Author

ryuukk commented Nov 29, 2021

You need to change the tests that are making this fail accordingly.

i'll look into it, thanks

  1. Can we really not have one error == one line here?

It wasn't really readable before as a one line

  1. Avoid mixing tabs and spaces.

I'll fix that

  1. 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..

@dkorpel
Copy link
Contributor

dkorpel commented Nov 29, 2021

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

@ibuclaw
Copy link
Member

ibuclaw commented Nov 29, 2021

  1. 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.

@nordlow
Copy link
Contributor

nordlow commented Dec 5, 2021

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?

@nordlow
Copy link
Contributor

nordlow commented Dec 5, 2021

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`

.

@ryuukk
Copy link
Contributor Author

ryuukk commented Dec 7, 2021

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!

  1. 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!

@RazvanN7
Copy link
Contributor

@ryuukk any progress on this?

@ryuukk
Copy link
Contributor Author

ryuukk commented Dec 16, 2021

@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

@moon-chilled
Copy link

%*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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants