Bug 15613 – Parameter type mismatch error message are not very helpful

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-01-26T13:31:26Z
Last change time
2022-11-01T17:41:45Z
Assigned to
No Owner
Creator
ponce

Comments

Comment #0 by aliloko — 2016-01-26T13:31:26Z
Example of such an error: -------------------- source\mymodule.d(244): Error: function distance.Distance.nextBuffer (const(float)* inputLeft, const(float)* inputRight, float distanceDB, float* outL, float* outR, int frames) is not callable using argument types (const(float*), const(float*), float, float[], float[], int) -------------------- One must mentally parse the entire message to find that parameter 3 and 4 should be float[] but are float*. It gets the worse the longer the function prototype is. It would be great if the compiler can do it and give the parameter index that mismatches.
Comment #1 by ketmar — 2016-01-27T06:36:07Z
or, at least, as a (possibly) simplier solution — prettyprint both declarations on separate lines, aligning arguments (possibly ommiting argument names), so it can be easily visually compared.
Comment #2 by nick — 2017-12-30T17:33:20Z
https://github.com/dlang/dmd/pull/7554 It shows the argument that failed (and matching parameter) rather than parameter index.
Comment #3 by nick — 2017-12-30T17:34:27Z
*** Issue 16165 has been marked as a duplicate of this issue. ***
Comment #4 by nick — 2018-01-02T13:32:54Z
*** Issue 9056 has been marked as a duplicate of this issue. ***
Comment #5 by github-bugzilla — 2018-01-26T06:36:42Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/48c6b49605e265e043e9a37fe6064ec603679619 Fix Issue 15613 - Parameter type mismatch error message not very helpful Show the first argument that fails to match the function parameters. This is also part of: Issue 9631 - Error message not using fully qualified name when appropriate https://github.com/dlang/dmd/commit/fcc69c18c439009508e1e57ea1f91970ffdf9b2b Merge pull request #7554 from ntrel/qual-arg Fix Issue 15613, 11529: Show parameter mismatch and rvalue/lvalue ref message merged-on-behalf-of: Sebastian Wilzbach <[email protected]>
Comment #6 by timothee.cour2 — 2018-02-26T22:56:28Z
re-opening, as the fix doesn't work with overloads: ``` --- main.d void fun(int a, double b){} version(with_overload) void fun(double a, int b){} void main(){ fun(1.1, 2.1); } ``` dmd main.d Error: function test_all.fun(int a, double b) is not callable using argument types (double, double) cannot pass argument 1.1 of type double to parameter int a dmd -version=with_overload main.d Error: none of the overloads of fun are callable using argument types (double, double), candidates are: test_all.fun(int a, double b) test_all.fun(double a, int b) with -version=with_overload , it should show a similar error showing where parameters mis-matcch
Comment #7 by dlang-bot — 2021-04-01T18:40:02Z
@ibuclaw created dlang/dmd pull request #12339 "[dmd-cxx] Backport fixes and trivial features from upstream dmd" mentioning this issue: - [dmd-cxx] Fix Issue 15613, 11529: Show parameter mismatch and rvalue/lvalue ref message https://github.com/dlang/dmd/pull/12339
Comment #8 by dlang-bot — 2021-04-02T05:45:21Z
dlang/dmd pull request #12339 "[dmd-cxx] Backport fixes and trivial features from upstream dmd" was merged into dmd-cxx: - 8f461425adb1e69bf02abf88b4e73585316b05af by Nick Treleaven: [dmd-cxx] Fix Issue 15613, 11529: Show parameter mismatch and rvalue/lvalue ref message https://github.com/dlang/dmd/pull/12339
Comment #9 by razvan.nitu1305 — 2022-10-31T13:32:55Z
The initial issue has been fixed, please do not reopen but file a new bug report when new manifestations of the bug appear. Now, for the overload example, I don't think that we should also take care of that one too. It has been the philosophy of D to not be too verbose with error messages. Imagine that if you have more than 2 functions in the overload set you will be littered with all of the information. I think that the current output is very nice and helpful: test.d(6): Error: none of the overloads of `fun` are callable using argument types `(double, double)` test.d(1): Candidates are: `test.fun(int a, double b)` test.d(3): `test.fun(double a, int b)` I think that this is enough. Anyway, if you do not agree, please file a new issue as this one has been fixed already.
Comment #10 by aliloko — 2022-11-01T17:41:45Z
Thanks, it saves us lotsa time!