Thread overview
[Issue 21377] Unclear error message "delegate __lambda cannot be struct members"
Dec 17, 2022
Iain Buclaw
November 11, 2020
https://issues.dlang.org/show_bug.cgi?id=21377

--- Comment #1 from bradley.chatha@gmail.com ---
Relevant quote from the forums: "The actual problem is that the compiler isn't able to figure out the type of the lambda you've provided. If you change the argument to `(string str)`, it'll work.

The real question is, why does type inference fail for the UDA when it works for the normal constructor call?"

--
November 12, 2020
https://issues.dlang.org/show_bug.cgi?id=21377

bradley.chatha@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
                 OS|Windows                     |All

--
January 28, 2021
https://issues.dlang.org/show_bug.cgi?id=21377

--- Comment #2 from bradley.chatha@gmail.com ---
I have a sneaking suspicion that this may be slightly related to one of the underlying problems for https://issues.dlang.org/show_bug.cgi?id=21496 which is where templated types that contain a template parameter into a struct member, will then implicitly become embedded within the struct itself.

So the anonymous lambda inside of `S2` in the example is being "falsely" embedded into `S2` which is causing this error, likely because the lambda is lowered into a form of template.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=21377

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=21377

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19818

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--