A simple example:
void foo(T)(T a, void delegate(T) dlg){}
Calling it like this works:
foo(1,(int x){});
foo!int(1,(x){});
But trying to call it like this:
foo(1,(x){});
Produces:
main.d(8): Error: template main.foo does not match any function template declaration. Candidates are:
main.d(5): main.foo(T)(T a, void delegate(T) dlg)
main.d(8): Error: template main.foo(T)(T a, void delegate(T) dlg) cannot deduce template function from argument types !()(int,void)
It seems that after reading the first argument `1` into `a`, the compiler knows that `T` is `int`, but when it starts reading the second argument `(x){}` into `dlg`, the compiler forgets that `T` is `int` and treats it as an unknown template parameter.
Might be related to Issue 9393
Comment #1 by robert.schadek — 2024-12-13T18:05:57Z