Bug 19389 – Multiple assignment does not work for struct members
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2018-11-10T10:50:54Z
Last change time
2018-12-12T13:46:32Z
Assigned to
No Owner
Creator
KytoDragon
Comments
Comment #0 by kytodragon — 2018-11-10T10:50:54Z
struct Foo {
int x;
this(int dummy) {
x = dummy;
}
}
struct Bar {
Foo a;
Foo b;
this(int dummy) {
a = (b = Foo(dummy));
}
}
void main() {
Foo a;
Foo b;
a = (b = Foo(7));
assert(b.x == 7 && a.x == 7); // works
Bar bar = Bar(7);
assert(bar.b.x == 7 && bar.a.x == 7); // !!! fails, bar.b.x is 0 !!!
}
This was discovered in LDC 1.12.0 and confirmed broken in DMD 2.082.0 .
According to run.dlang.io, this has worked from v2.060 to 2.069, and fails since 2.070.