This code doesn't work:
--------------
void foo(Ret)(Ret delegate(int) dg) { }
// Even though alias func is not specified,
// this is selected unnaturally.
// Also, if this function is commented out,
// the above function(foo(Ret)) is inferred.
void foo(alias func)(void delegate(string) dg) { }
void main()
{
foo(a => a + 1);
}
--------------
dmd -run main.d
--------------
main.d(11): Error: incompatible types for `(a) + (1)`: `string` and `int`
Comment #1 by b2.temp — 2018-09-12T16:25:42Z
I don't know if there's a bug or an enhancement possible in the compiler. Selecting the right overload is trivial:
```
foo((int a) => a + 1);
```
If this solution is satisfying you can set the Status as RESOLVED for the reson INVALID.
Comment #2 by b2.temp — 2018-09-12T16:35:28Z
Problem is also that the specs for this kind of stuff are void. Looks like only the last overload of the overload set is tried.
Comment #3 by robert.schadek — 2024-12-13T19:00:32Z