Skip to content
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

Merged
merged 1 commit into from
Feb 12, 2018

Conversation

RazvanN7
Copy link
Contributor

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.

@dlang-bot
Copy link
Contributor

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • My PR follows the DStyle
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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

Auto-close Bugzilla Severity Description
17970 regression shared struct destructor doesn't compile anymore

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

@wilzbach
Copy link
Member

See also: #7566 (for disallowing shared destructors)

@@ -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)
Copy link
Member

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;
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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)

@wilzbach
Copy link
Member

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.

This explanation should be in the source code ;-)

@andralex
Copy link
Member

I'll approve this because it doesn't compete with #7566 and unblocks other students' work.

@dlang-bot dlang-bot merged commit 2c70923 into dlang:master Feb 12, 2018
@jacob-carlborg
Copy link
Contributor

This explanation should be in the source code ;-)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants