Skip to content

Commit 1a3290f

Browse files
committed
Fix dlang#22613 - consecutive initialization fails with postblits
1 parent 720f0e0 commit 1a3290f

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

compiler/src/dmd/expressionsem.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12424,7 +12424,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1242412424
}
1242512425

1242612426
/* Rewrite as:
12427-
* (e1 = e2).postblit();
12427+
* (e1 = e2).postblit(), e1;
1242812428
*
1242912429
* Blit assignment e1 = e2 returns a reference to the original e1,
1243012430
* then call the postblit on it.
@@ -12436,6 +12436,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1243612436
e = new BlitExp(exp.loc, e, e2x);
1243712437
e = new DotVarExp(exp.loc, e, sd.postblit, false);
1243812438
e = new CallExp(exp.loc, e);
12439+
e = new CommaExp(exp.loc, e, e1x);
1243912440
result = e.expressionSemantic(sc);
1244012441
return;
1244112442
}

compiler/test/runnable/sctor.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,11 @@ struct S22604
485485

486486
struct T22604
487487
{
488-
S22604 a, b;
488+
S22604 a, b, c, d;
489489

490490
this(int)
491491
{
492-
a = b = S22604(1);
492+
a = b = c = d = S22604(1);
493493
}
494494
}
495495

@@ -498,6 +498,8 @@ void test22604()
498498
T22604 t = T22604(1);
499499
assert(t.a.ptr is &t.a);
500500
assert(t.b.ptr is &t.b);
501+
assert(t.c.ptr is &t.c);
502+
assert(t.d.ptr is &t.d);
501503
}
502504

503505
/***************************************************/

0 commit comments

Comments
 (0)