-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Fix Issue 17970 - shared struct destructor doesn't compile anymore #7874
Conversation
|
Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
|
|
See also: #7566 (for disallowing shared destructors) |
src/dmd/dtemplate.d
Outdated
| @@ -2422,6 +2422,17 @@ void functionResolve(Match* m, Dsymbol dstart, Loc loc, Scope* sc, Objects* tiar | |||
| else | |||
| return 0; // MATCH.nomatch | |||
| } | |||
| auto dt = fd.isDtorDeclaration(); | |||
| if (dt) | |||
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 (auto dt = fd.isDtorDeclaration())
| if (shared_dtor && !shared_this) | ||
| tthis_fd = dtmod; | ||
| else if (shared_this && !shared_dtor) | ||
| tf.mod = tthis_fd.mod; |
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.
What's about the case of shared_this && shared_dtor?
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 either the struct/class declaration is shared or the destructor is shared, it makes sure that when the matching is done, both are considered shared.
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.
(I asked because such motivation belongs into the source code - it will help people in the future and also the review of this PR)
This explanation should be in the source code ;-) |
349ce29 to
8a61a31
Compare
|
I'll approve this because it doesn't compete with #7566 and unblocks other students' work. |
Putting it in the commit message is also good. When a PR only consists of one commit GitHub will automatically use the commit messages as the title and description for the PR. |
The problem here is that if a struct is declared as shared the dtor is automatically considered to be shared, but when the struct is instantiated the instance is no longer considered to be shared when the function call matching is done. The fix makes it so that if a struct declaration is shared, when the destructor is called, the instantiated struct is also considered shared.