Thread overview
[Issue 20498] A way to initialize a struct of delegates with no-op stubs?
Feb 20, 2020
Basile-z
Dec 17, 2022
Iain Buclaw
January 20, 2020
https://issues.dlang.org/show_bug.cgi?id=20498

--- Comment #1 from hsteoh@quickfur.ath.cx ---
Rainer Scheutze found this workaround:

------
void noop(int) {}
enum void delegate(int) dg_noop = (int x){ noop(x); };
struct S {
    void delegate(int) dg = dg_noop;
}
------

which can be applied to the original case as:
------
enum void delegate(Args) doNothing(Args...) = (Args args) {};
struct S {
    void delegate(int) dg1 = doNothing!int;
    void delegate(string, int) dg2 = doNothing!(string,int);
    ...
}
------

However he comments that it's a bug:

> I think it's a bug in the compiler. If you can assign an enum value, why
should the value itself not be good enough aswell?

--
February 20, 2020
https://issues.dlang.org/show_bug.cgi?id=20498

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
*** Issue 13494 has been marked as a duplicate of this issue. ***

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

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

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

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

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

--