Skip to content

Commit

Permalink
Merge pull request #9066 from WalterBright/fix19389
Browse files Browse the repository at this point in the history
fix Issue 19389 - Multiple assignment does not work for struct members
merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
  • Loading branch information
dlang-bot authored Dec 12, 2018
2 parents 20d13c6 + 62500a6 commit 9f849a4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -7843,6 +7843,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
DotVarExp dve = (ce && ce.e1.op == TOK.dotVariable)
? cast(DotVarExp)ce.e1 : null;
if (sd.ctor && ce && dve && dve.var.isCtorDeclaration() &&
// https://issues.dlang.org/show_bug.cgi?id=19389
dve.e1.op != TOK.dotVariable &&
e2y.type.implicitConvTo(t1))
{
/* Look for form of constructor call which is:
Expand Down
28 changes: 28 additions & 0 deletions test/runnable/sctor.d
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,33 @@ void test15869()
assert(xx.a.value == 1);
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=19389

struct Foo19389 {
int x;

this(int dummy) { x = dummy; }
}

struct Bar19389 {
Foo19389 a;
Foo19389 b;

this(int dummy) {
a = (b = Foo19389(dummy));
}
}


void test19389()
{
Bar19389 bar = Bar19389(7);
assert(bar.a.x == 7);
assert(bar.b.x == 7); // fails
}


/***************************************************/

int main()
Expand All @@ -458,6 +485,7 @@ int main()
test14944();
test15665();
test15869();
test19389();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 9f849a4

Please sign in to comment.