Bug 21003 – Lambda/delegate as default value for member function argument "cannot be struct members"

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-07-01T15:23:37Z
Last change time
2024-12-13T19:09:50Z
Assigned to
No Owner
Creator
Stanislav Blinov
Moved to GitHub: dmd#19737 →

Comments

Comment #0 by stanislav.blinov — 2020-07-01T15:23:37Z
struct S { void foo(int value) { bar(() => value); } void bar(Dg)(Dg dg = () => 0) { import std.stdio; writeln(dg()); } } In the above, the call to `bar` inside `foo` fails to compile with: bug.d(8): Error: delegate bug.S.bar(Dg)(Dg dg = () => 0) cannot be struct members
Comment #1 by stanislav.blinov — 2020-07-01T16:35:08Z
Further reduction, `bar` doesn't need to be a template, e.g. struct S { void foo(int value) { bar(() => value); } void bar(int delegate() dg = () => 0) { import std.stdio; writeln(dg()); } } bug.d(8): Error: delegate bug.S.__lambda3 cannot be struct members
Comment #2 by robert.schadek — 2024-12-13T19:09:50Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19737 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB