Skip to content

[5.9🍒] _forget usage fixes to match SE-390 #65743

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

Merged
merged 3 commits into from
May 7, 2023

Conversation

kavon
Copy link
Member

@kavon kavon commented May 6, 2023

• Description: A bundle of changes to usages of the _forget statement to match SE-390. See the commits for details but the TLDR is: (1) emit an error if _forget is in an initializer, as it was being permitted there in addition to consuming methods; (2) emit an error if _forget is used in a type with no deinit, since there's no reason to use _forget at all; (3) require only "trivially destructed" storage in a type with a _forget, since we don't yet have the semantics we want implemented if you have storage that requires destruction.
• Risk: Low-ish. Could lead to source breaks that are trivial to fix for (1) and (2); just define a consuming func forget() { _forget self } if you used it in an initializer. For (3) it's a harder but necessary source break that is better to make now than later. It shouldn't affect early adopters that I'm aware of.
• Original PR: #65690
• Reviewed By: @airspeedswift
• Testing: regression tests included
• Resolves: rdar://108877261

kavon added 3 commits May 6, 2023 11:59
we decided against allowing it for now.

rdar://108877261
(cherry picked from commit 7ac3ea0)
rdar://108877261
(cherry picked from commit 4943beb)
We haven't quite got the semantics we want implemented
for `discard` aka `_forget` statements. Allowing people
to use `_forget` in noncopyable types that have stored
properties that require destruction will not let us
implement it the way we'd like in the future without
source break. But, if the type only has "trivial" stored
properties with a no-op destruction, like `Int`, then we
can still provide utility for users like FileDescriptor
who just want to disable the deinit and have nothing
fancy stored in the type itself.

rdar://108877261
(cherry picked from commit 578da49)
@kavon kavon requested a review from a team as a code owner May 6, 2023 19:10
@kavon
Copy link
Member Author

kavon commented May 6, 2023

@swift-ci please test

@kavon kavon requested review from jckarter, gottesmm and atrick May 6, 2023 19:11
@airspeedswift
Copy link
Member

SE-0390 also renamed it to discard, right? Is that going to be done separately?

@kavon
Copy link
Member Author

kavon commented May 7, 2023

yes the discard change will be a separate PR.

@kavon kavon merged commit 9525386 into swiftlang:release/5.9 May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants