Skip to content

[6.2] Fix a lifetime dependence diagnostic #82810

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 1 commit into from
Jul 7, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jul 4, 2025

LifetimeDescriptor::getName() can crash if the descriptor had a self.
Replace with LifetimeDescriptor::getString()

(cherry picked from commit 6d0a6d2)

--- CCC ---

Explanation: Fixes a compiler crash when reporting a lifetime diagnostic error.

Scope: This only affects adopters of experimental but supported @_lifetime syntax. The following sytax would crash:

struct S {
  @_lifetime(self: &self)
  func foo() {}
}

This only occurs with invalid input, but it is easy to make this mistake because we have diagnostics suggesting this syntax when the method is mutating. And it is common to convert methods between mutating and nonmutating forms.

Radar/SR Issue: rdar://155056801 ([nonescapable] compiler crash on invalid input: @Lifetime(self: &self))

main PR: #82787

Risk: Low. This change only touches the diagnostic output.

Testing: Added source-level unit test.

Reviewer: Meghana Gupta (author)

`LifetimeDescriptor::getName()` can crash if the descriptor had a `self`.
Replace with `LifetimeDescriptor::getString()`

(cherry picked from commit 6d0a6d2)
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jul 4, 2025
@atrick atrick requested a review from a team as a code owner July 4, 2025 18:59
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jul 4, 2025
@atrick
Copy link
Contributor Author

atrick commented Jul 4, 2025

@swift-ci test

@atrick atrick requested review from meg-gupta and tbkka July 4, 2025 19:00
@atrick atrick merged commit 61a4ee9 into swiftlang:release/6.2 Jul 7, 2025
5 checks passed
@atrick atrick deleted the 62-lifetimediag branch July 7, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants