[Issue 17477] DMD error message for delegate with wrong attributes is very confusing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 19 16:02:26 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=17477

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #3 from Nick Treleaven <nick at geany.org> ---
> This is wrong, as the argument type is not (void).

The type of a template is void. A lambda without parameter types is a template.
When a template lambda doesn't implicitly convert to the expected parameter
type, it's not established what the type of the implicitly instantiated lambda
is, as it failed to instantiate.

> It is also very difficult to figure out what is wrong with this program from this error (when the code is far more complicated).

The fix for issue #10602 gives:

/home/nick/old/lambdaarg.d(16): Error: function `lambdaarg.f(void delegate(int)
nothrow dlg)` is not callable using argument types `(void)`
/home/nick/old/lambdaarg.d(16):        cannot implicitly convert expression
`__lambda2` of type `void delegate(int x) @system` to `void delegate(int)
nothrow`

Note the inferred argument type that the compiler tried on the second line.

--


More information about the Digitalmars-d-bugs mailing list