Bug 7061 – delegates sometimes cannot be used in struct initializers
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-12-03T06:27:46Z
Last change time
2020-03-21T03:56:41Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
timon.gehr
Comments
Comment #0 by timon.gehr — 2011-12-03T06:27:46Z
S a = {{}}; // fail
S b = {{;}}; // fail
S c = {{x=0;}}; // fail
T d = {{return 0;}}; // fail
void main(){
S x = {{}}; // ok
S y = {{;}}; // fail
S z = {{x=0;}}; // fail
T w = {{return 0;}}; // fail
}
The program should compile. The inconsistency between x and y suggests that the issue is partly related to the parser.
Comment #1 by dlang-bugzilla — 2017-07-02T01:47:19Z
Timon, fairly sure that's not the entire program. What's the definition of S?
Comment #2 by timon.gehr — 2017-07-02T03:37:34Z
(In reply to Vladimir Panteleev from comment #1)
> Timon, fairly sure that's not the entire program. What's the definition of S?
Oops. Thanks! The entire program:
struct S{ void delegate() dg; }
struct T{ int delegate() dg; }
int x;
S a = {{}}; // fail
S b = {{;}}; // fail
S c = {{x=0;}}; // fail
T d = {{return 0;}}; // fail
void main(){
S x = {{}}; // ok
S y = {{;}}; // fail
S z = {{x=0;}}; // fail
T w = {{return 0;}}; // fail
}
Comment #3 by b2.temp — 2019-07-23T01:25:00Z
struct S{ void delegate() dg; }
struct T{ int delegate() dg; }
int x;
S a = {{}}; // ok
S b = {{;}}; // ok
S c = {{x=0;}}; // ok
T d = {{return 0;}}; // ok
void main(){
int g;
S x1 = {{}}; // ok
S y = {{;}}; // ok
S z = {{x=0;}}; // ok
T w = {{return 0;}}; // ok
}