New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Fix Issue 11292 - Cannot re-initialize a const field in postblit" #11921
Conversation
Thanks for your pull request, @ibuclaw! Bugzilla references
|
I don't think it's that simple - technically, a normal ctor (incl. copy ctor) doesn't initialize the memory either, that's done by the implicit struct GrayArea
{
BatchState low;
this(int x)
{
low = low.copy;
low.arr[0] += x;
}
}
void main()
{
GrayArea a = GrayArea(1);
assert(a.low.arr[0] == 1); // fails, is 2
} I expected the original change to circumvent immutability, at least for the first assignment, but not via a promotion from |
https://github.com/dlang/dmd/blob/master/src/dmd/declaration.d#L432-L433 I think this should really be done using another method, as there seems to be some blurring of lines going on over whether an assignment is initializing or modifying. |
Maybe just avoid converting
|
That won't do as genuine construct assignments would not have the right codegen now. |
FWIW, I think this is good to go.
I doubt that; I guess working around non-mutability requires the The proper way to allow a re-init of non-mutable fields in the postblit probably requires keeping it an |
@BorisCarvajal's proposed change is in the AssignExp semantic, so that would mean:
Would not be a construct expression if that condition were added, though I'll ignore this as I'm digressing about matters that I have no desire about. :-)
My thoughts are perhaps |
Ping? |
Reverts #11190
Rationale for revert, a postblit does not construct new memory, as can be shown in the failing test in https://issues.dlang.org/show_bug.cgi?id=21357