Bug 21753 – Struct literal with function literal member not allowed as template value argument
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-24T02:43:25Z
Last change time
2021-04-03T11:13:08Z
Keywords
pull
Assigned to
No Owner
Creator
Boris Carvajal
Comments
Comment #0 by boris2.9 — 2021-03-24T02:43:25Z
From: https://forum.dlang.org/post/[email protected]
```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.
Comment #1 by dlang-bot — 2021-03-24T02:52:02Z
@BorisCarvajal created dlang/dmd pull request #12300 "Fix Issue 21753 - Struct literal with function literal member not allowed" fixing this issue:
- Fix Issue 21753 - Struct literal with function literal member not allowed as template value argument
https://github.com/dlang/dmd/pull/12300
Comment #2 by dlang-bot — 2021-03-24T04:40:06Z
dlang/dmd pull request #12300 "Fix Issue 21753 - Struct literal with function literal member not allowed" was merged into master:
- abe4ac1b6a3b89865076cc6f33ff18f29d24bd58 by Boris Carvajal:
Fix Issue 21753 - Struct literal with function literal member not allowed as template value argument
https://github.com/dlang/dmd/pull/12300
Comment #3 by dlang-bot — 2021-04-03T11:13:08Z
dlang/dlang.org pull request #2989 "abi: add mangling for issue 21753" was merged into master:
- e268c4b79dd79aa1198f48372bad86f695c0f40c by Boris Carvajal:
abi: add mangling for issue 21753
https://github.com/dlang/dlang.org/pull/2989