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.
https://github.com/dlang/dmd/pull/9066
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/62500a6162958efa6d3ecb518abda3ae2f5faef6 fix Issue 19389 - Multiple assignment does not work for struct members https://github.com/dlang/dmd/commit/9f849a4a470c4c5c0fba4af3739aca6250615e56 Merge pull request #9066 from WalterBright/fix19389 fix Issue 19389 - Multiple assignment does not work for struct members merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>