Fix issue 16142: Disabled opAssign is overriden when a dtor/postblit is present#5854
Fix issue 16142: Disabled opAssign is overriden when a dtor/postblit is present#5854WalterBright merged 1 commit intodlang:masterfrom mathias-lang-sociomantic:opassign-2
Conversation
|
|
|
||
| // One of our sub-field might have `@disable opAssign` so we need to | ||
| // check for it. | ||
| for (size_t i = 0; i < sd.fields.dim; i++) |
There was a problem hiding this comment.
Use foreach (i; 0 .. sd.fields.dim) or foreach (field; sd.fields) (if it works).
There was a problem hiding this comment.
I'm merely moving things around and adding documentation here.
I have further plans for this part of the code so I'll keep this comment in mind for later.
|
Depends on dlang/phobos#4421 |
|
Alright, there are a couple of other issues with |
|
It's green. @WalterBright @andralex : Pinging you for language change. Currently, According to the specs, an elaborate However, as it was recently outlined on the forums by 2 different users ( @deadalnix here and Eyal from Weka), one might want to use postblit + identity opAssign to ensure consistency or avoid unwanted copy/move, which is not possible at the moment. As a result, this P.R. is a first step in |
|
Why does this say it's about opEquals when it's about opAssign? Please fix! |
| Loc loc = Loc(); // internal code should have no loc to prevent coverage | ||
|
|
||
| // One of our sub-field might have `@disable opAssign` so we need to | ||
| // check for it. |
There was a problem hiding this comment.
Might want to add that the purpose of the next block of code is to set stc.
Oops, fixed. |
|
@WalterBright : Just to be on the safe side: are you okay with the plan outlined here ? :) |
…is present In order to pick up disabled opEquals, we need to process the members of the struct anyway even if there is a dtor / postblit.
|
Updated: diff --git a/src/clone.d b/src/clone.d
index ddf72cc..8d1899b 100644
--- a/src/clone.d
+++ b/src/clone.d
@@ -209,6 +209,8 @@ extern (C++) FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)
// One of our sub-field might have `@disable opAssign` so we need to
// check for it.
+ // In this event, it will be reflected by having `stc` (opAssign's
+ // storage class) include `STCdisabled`.
for (size_t i = 0; i < sd.fields.dim; i++)
{
VarDeclaration v = sd.fields[i];
@WalterBright : Ping on #5854 (comment) |
|
Auto-merge toggled on |
In order to pick up disabled opEquals, we need to process the members
of the struct anyway even if there is a dtor / postblit.