Bug 13869 – Not good error message with not compatible lambda template argument

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-12-16T11:05:52Z
Last change time
2024-12-13T18:38:29Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18923 →

Comments

Comment #0 by bearophile_hugs — 2014-12-16T11:05:52Z
void foo(double function(double) @safe, double function(double) @safe) {} void main() { enum real y = 1; foo(x => double(y), x => x); // line 5, OK foo(x => y, x => x); // line 6, Error } dmd 2.067alpha gives: test.d(6,8): Error: function test.foo (double function(double) @safe _param_0, double function(double) @safe _param_1) is not callable using argument types (void, void) The line 5 is correct because the two given template lambdas match the functions in the 'foo' signature. While the line 6 is not correct because the first lambda template returns a real, that is not compatible with a function that returns a double. In both lines the second lambda template is correct, but the error message gives a "(void, void)", so if the first lambda template doesn't match, the second isn't even tried. This doesn't help me find what of the two lambdas is the wrong one. And even for the first lambda template, giving just a "void" when the given lambda template returns a real instead of a double seems excessive. So ideally I'd like an error message more like: test.d(6,8): Error: function test.foo(double function(double) @safe _param_0, double function(double) @safe _param_1) is not callable using argument types (real function(double) @safe, double function(double) @safe), the first argument doesn't match
Comment #1 by robert.schadek — 2024-12-13T18:38:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18923 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB