-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
Issue 10194. Variant does not call struct destructors. #2147
Conversation
LGTM |
@@ -561,6 +578,16 @@ public: | |||
opAssign(value); | |||
} | |||
|
|||
this(this) | |||
{ | |||
fptr(OpID.postblit, &store, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this covered by the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's implicitly covered by lots of tests. But i can add an "explicit" test for that, if needed.
ping |
Well, the only update I have, is trying to call opAssign when appropriate appeared to be a really bulky solution, which I'm not proud of, also it has some bugs, and I didn't manage to debug it yet. I would be really happy if you guys accept the current "always-destruct-on-assign" solution. If you think of that as RAII support, it should be almost-the-same semantically. Also opAssign support could be an additional improvement with a separate PR. What do you think? |
I agree. While missing opAssign support will be rather annoying bug current situation is MUCH worse and this PR improves it. |
Auto-merge toggled on |
Still, if you can come up with update PR which adds opAssign support, that will be very appreciated ;) |
Issue 10194. Variant does not call struct destructors.
Thanx! Regarding opAssign - I'll try my best =) |
This pull request introduced a regression: |
This pull request introduced a regression: |
Thats a shame. I can suggest the following solutions:
|
@@ -544,6 +547,20 @@ private: | |||
} | |||
break; | |||
|
|||
case OpID.postblit: | |||
static if (hasElaborateAssign!A) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to check that A
has an elaborate copy operation, you should use std.traits.hasElaborateCopyConstructor
.
Check for elaborate copying corrected: 2437 |
The bugs remain open though. The problem is that variant.postblit is not pure. Also, it's not safe and it may throw. Purity, safety and nothrowness are runtime properties of Variant. So maybe it would be safer to always treat variant.postblit as non-pure, @System and throwing, and wrapping it's postblit in assume-blocks where appropriate. And in such case those bugs are no more bugs. |
This PR has introduced regression https://issues.dlang.org/show_bug.cgi?id=13871 which is still present in Phobos master. |
Quick fix: #2826. |
This pull request introduced a regression: (This was known since 2015-01-31, I'm only posting here to notify the PR participants) |
First commit fixes issue 10194
The second commit adds support for elaborate copying.