Bug 22693 – Lambda accepts auto parameter but fails on instantiation

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-01-20T22:15:52Z
Last change time
2024-12-13T19:20:30Z
Assigned to
No Owner
Creator
Luís Ferreira
Moved to GitHub: dmd#20041 →

Comments

Comment #0 by contact — 2022-01-20T22:15:52Z
The compiler accepts the following: ``` alias func = (auto c) {}; ``` But when instantiation `func` with some value it fails: ``` func(4); ``` Producing the following error: ``` onlineapp.d(4): Error: `auto` can only be used as part of `auto ref` for template function parameters onlineapp.d(5): Error: template `D main.__lambda1` cannot deduce function from argument types `!()(int)` onlineapp.d(4): Candidate is: `__lambda1` ``` We should either fail when declaring lambdas with auto or add support for it. If we want to add support for this, templates should also cover it, to make it consistent with all the language semantics.
Comment #1 by robert.schadek — 2024-12-13T19:20:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20041 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB