Comment #0 by ali.akhtarzada — 2017-12-06T10:40:16Z
When you declare a template lambda:
immutable lambda(T) = (T n) => n * n;
and call it without an explicit type it errors with with:
lambda cannot deduce function from argument types !()(int)
auto x = lambda!int(2); // works
auto x = lambda(2); // not works
Is this a bug? - tired on dmd v2.077.1
Comment #1 by schveiguy — 2017-12-06T15:43:47Z
Tested back to 2.070.0, which is where short lambda syntax was introduced. Still fails.
The immutable looks odd, but even with alias this doesn't work.
alias lambda(T) = (T n) => n * n;
should expand to:
template lambda(T)
{
alias lambda = (T n) => n * n;
}
Neither of these successfully use IFTI.
However, these all work:
alias lambda = (int n) => n * n;
alias lambda = n => n * n;
Comment #2 by robert.schadek — 2024-12-13T18:55:15Z