March 24, 2021 [Issue 21753] New: Struct literal with function literal member not allowed as template value argument | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21753 Issue ID: 21753 Summary: Struct literal with function literal member not allowed as template value argument Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: boris2.9@gmail.com From: https://forum.dlang.org/post/syxnzddlnkfwtbvrdfsr@forum.dlang.org ```d import std.stdio; struct Sample{ void function() func1; void function() func2; } void noth(Sample smpl)() { smpl.func1(); // Error: expression __lambda1 is not a valid template value argument smpl.func2(); // Error: expression __lambda2 is not a valid template value argument } void main(){ enum s = Sample( {writeln("Hello world1");}, {writeln("Hello world2");} ); s.func1(); s.func2(); noth!(s)(); } ``` A function literal can be a template value argument and the spec says that "struct literals of template value arguments" are too, so this should be allowed. -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply