Bug 18037 – Lambda with specified template type parameter does not work with IFTI

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-12-06T10:40:16Z
Last change time
2024-12-13T18:55:15Z
Assigned to
No Owner
Creator
Ali Ak
See also
https://issues.dlang.org/show_bug.cgi?id=15499
Moved to GitHub: dmd#19339 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19339 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB