D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19389 - Multiple assignment does not work for struct members
Summary: Multiple assignment does not work for struct members
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-10 10:50 UTC by KytoDragon
Modified: 2018-12-12 13:46 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description KytoDragon 2018-11-10 10:50:54 UTC
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.
Comment 1 Walter Bright 2018-12-11 08:21:25 UTC
https://github.com/dlang/dmd/pull/9066
Comment 2 github-bugzilla 2018-12-12 13:46:31 UTC
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>