Comment #1 by pro.mathias.lang — 2020-05-15T03:50:17Z
The behavior of this has changed a bit.
First, qualified postblits are deprecated. Taking away the qualified, the second test passes, but not the third one. However postblit is going to be deprecated in the future so I doubt this'll get fixed. Leaving open until the postblit deprecation though...
Comment #2 by bugzilla — 2020-08-09T08:43:59Z
Yes, this will get a WONTFIX.
Comment #3 by kinke — 2020-10-17T16:20:11Z
Copy ctors are currently (wrongly) ignored when copying static arrays: https://issues.dlang.org/show_bug.cgi?id=20365
This issue here is pretty bad and inconsistent - the postblit is called correctly for mutable copies and scalar non-mutable copies, only non-mutable static array copies ignore the postblit:
void main()
{
static struct S
{
int x = 42;
this(this) { x += 10; }
}
{
S source;
S mutableCopy = source;
assert(mutableCopy.x == 52);
const S constCopy = source;
assert(constCopy.x == 52);
}
{
S[1] source;
auto mutableCopy = source;
assert(mutableCopy[0].x == 52);
const constCopy = source;
assert(constCopy[0].x == 52); // fails
immutable immutableCopy = source;
assert(immutableCopy[0].x == 52); // fails
}
}
Comment #4 by razvan.nitu1305 — 2023-03-29T12:08:32Z
Issue 20365 has been fixed and kinke's code and the original provided code do not assert anymore. Closing as WORKSFORME.