Bug 10602 – Error should state why wrong template lambda doesn't match expected function type

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-10T17:36:48Z
Last change time
2024-12-13T18:09:07Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
bearophile_hugs
See also
https://issues.dlang.org/show_bug.cgi?id=17477, https://issues.dlang.org/show_bug.cgi?id=9423
Moved to GitHub: dmd#18626 →

Comments

Comment #0 by bearophile_hugs — 2013-07-10T17:36:48Z
This is wrong code: void foo(int function(int) f) {} void main() { foo(x => 0); // OK foo(x => 0.0); // Error foo((x, y) => 0); // Error } DMD 2.064alpha gives: test.d(4): Error: function test.foo (int function(int) f) is not callable using argument types (void) test.d(5): Error: function test.foo (int function(int) f) is not callable using argument types (void) I suggest to try to generate better error messages here, that better explain the problem to the programmer.
Comment #1 by nick — 2023-02-01T22:07:42Z
It now also prints e.g.: badlambda.d(4): cannot pass argument `__lambda2` of type `void` to parameter `int function(int) f` It would be nice if it said: (4): Error: lambda returns `double`, expected `int` (5): Error: lambda does not accept arguments `(int)`
Comment #2 by dlang-bot — 2023-08-19T15:18:18Z
@ntrel created dlang/dmd pull request #15544 "Fix Issue 10602 - Error should state why wrong template lambda doesn'…" fixing this issue: - Fix Issue 10602 - Error should state why wrong template lambda doesn't match expected function type https://github.com/dlang/dmd/pull/15544
Comment #3 by robert.schadek — 2024-12-13T18:09:07Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18626 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB