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 bugzilla 24596: std.typecons.Rebindable2: Don't destroy classes! Only destroy structs! #9012

Conversation

FeepingCreature
Copy link
Contributor

@FeepingCreature FeepingCreature commented Jun 10, 2024

PR fixes #8768 for classes.

object.destroy is, perhaps appropriately, the most destructive function ever written.

It does something useful (resetting the value and calling the destructor) for structs and struct derivatives, but something horrible (destroying the class data) for objects. So you're always tempted to use it, but you have to remember, every time, to disable the cases where it silently causes future crashes.

I forgot this time.

edit: core.internal.container.common.destroy looks like it does it right... Maybe I just switch to that? Is that safe to call from std.typecons?

@dlang-bot
Copy link
Contributor

dlang-bot commented Jun 10, 2024

Thanks for your pull request and interest in making D better, @FeepingCreature! 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 coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • 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
24596 critical Rebindable2 corrupts objects

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + phobos#9012"

@FeepingCreature FeepingCreature changed the base branch from master to stable June 10, 2024 09:53
@FeepingCreature FeepingCreature changed the title Fix bugzilla issue 24596: std.typecons.Rebindable2: Don't destroy classes! Only destroy structs! Fix bugzilla 24596: std.typecons.Rebindable2: Don't destroy classes! Only destroy structs! Jun 10, 2024
@FeepingCreature FeepingCreature force-pushed the fix/bugzilla-issue-24596-rebindable2-corrupts-objects branch from 14ba49b to e8e1fc1 Compare June 10, 2024 09:54
@FeepingCreature FeepingCreature force-pushed the fix/bugzilla-issue-24596-rebindable2-corrupts-objects branch from e8e1fc1 to ed41b39 Compare June 10, 2024 11:15
@thewilsonator thewilsonator merged commit 539dc47 into dlang:stable Jun 10, 2024
10 checks passed
@FeepingCreature FeepingCreature deleted the fix/bugzilla-issue-24596-rebindable2-corrupts-objects branch June 10, 2024 15:12
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.

3 participants