Bug 20625 – Function literal diagnostic is not on par with other messages
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-03-02T09:46:21Z
Last change time
2020-03-02T11:51:47Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
Mathias LANG
Comments
Comment #0 by pro.mathias.lang — 2020-03-02T09:46:21Z
The following code:
```
void main()
{
// No argument
(x, y, z) { return 42; }();
// Too many args, non-variadic
(x, y, z) { return 42; }(42, "Hello", 42, 42);
// Too many args, non-variadic, default param
(x, y, string z = "Hello") { return x; }(42, 42, "Nope", "Noooope");
// Too few args, non-variadic
(x, y, string z = "Hello") { return x; }(42);
// Too few args, non-variadic, default param
(x, y, z) { return x; }(42);
// Too few args, variadic
(x, y, ...) { return x; }(42);
// Too few args, variadic, default param
(x, y, string z = "Hey", ...) { return x; }(42);
}
```
Outputs the following:
```
diag1111.d(4): Error: function literal __lambda1(x, y, z) is not callable using argument types ()
diag1111.d(4): missing argument for parameter #1: x
diag1111.d(7): Error: cannot infer function literal type
diag1111.d(9): Error: cannot infer function literal type
diag1111.d(11): Error: cannot infer function literal type
diag1111.d(13): Error: cannot infer function literal type
diag1111.d(16): Error: cannot infer function literal type
diag1111.d(18): Error: cannot infer function literal type
```
You can see that the first error message, with no argument, is pretty good, while the other error messages are much poorer.
Comment #1 by dlang-bot — 2020-03-02T10:07:54Z
@Geod24 updated dlang/dmd pull request #10855 "Fix issue 20625: Improve diagnostics and test immediately called function literals" fixing this issue:
- Fix issue 20625: Improve diagnostics and test immediately called function literals
The didn't seem to be any test in the testsuite covering this.
Additionally, the error message was just awful,
and our users are used to so much better nowadays.
https://github.com/dlang/dmd/pull/10855
Comment #2 by dlang-bot — 2020-03-02T11:51:47Z
dlang/dmd pull request #10855 "Fix issue 20625: Improve diagnostics and test immediately called function literals" was merged into master:
- a19b505912df9e36fa8b21e3f77ffb3decba16c5 by Geod24:
Fix issue 20625: Improve diagnostics and test immediately called function literals
The didn't seem to be any test in the testsuite covering this.
Additionally, the error message was just awful,
and our users are used to so much better nowadays.
https://github.com/dlang/dmd/pull/10855