Skip to content

[6.2] Handle unsafe pattern match expressions correctly #81677

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 2 commits into from
May 22, 2025

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented May 21, 2025

  • Explanation: An unsafe expression within pattern match expressions (e.g., case unsafe someValue within a switch) was not covering the implicitly generated use of the pattern match operator (=~), leading to strict memory safety warnings that could not be suppressed.
  • Scope: Limited to strict memory safety when checking switches.
  • Issues: rdar://151731850
  • Original PRs: [Strict memory safety] Lift "unsafe" in pattern match expressions #81675
  • Risk: Very low. Narrow change that only affects warnings.
  • Testing: CI, new tests.
  • Reviewer: @AnthonyLatsis

When an "unsafe" expression is used as the case expression, lift it up
so it also covers the synthesized matching expression (`=~`). This
eliminates some unsuppressible strict memory safety warnings.

Fixes rdar://151731850.
Use the argument type rather than the (potentially generic) parameter type.
@DougGregor DougGregor requested a review from a team as a code owner May 21, 2025 12:54
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test Linux

@DougGregor DougGregor enabled auto-merge May 21, 2025 22:17
@DougGregor DougGregor merged commit 214536e into swiftlang:release/6.2 May 22, 2025
5 checks passed
@DougGregor DougGregor deleted the unsafe-pattern-match-6.2 branch May 22, 2025 06:57
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