Skip to content

[5.9] [Sema] Allow if/switch expressions in optional chain assignments #65920

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 16, 2023

Conversation

hamishknight
Copy link
Contributor

5.9 cherry-pick of #65915, based on #65905

  • Explanation: Fixes an issue where an if/switch expression would be incorrectly rejected when used in an assignment to an optional chain.
  • Scope: Affects if/switch expressions used in assignments.
  • Issue: rdar://109305454
  • Risk: Low
  • Testing: Added tests to the test suite
  • Reviewer: Pavel Yaskevich

Previously we could miss the scopes present in
if/switch expressions if they were nested in
another expression, such as an AssignExpr. Fix
the logic such that we properly walk over a given
expression looking for if/switch scopes, the same
as what we do for closures.

rdar://109192116
Make sure we look through a wrapping
`OptionalEvaluationExpr` and its injections when
looking for an assignment to mark a valid if/switch
source expression.

rdar://109305454
@hamishknight hamishknight added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels May 15, 2023
@hamishknight hamishknight requested a review from a team as a code owner May 15, 2023 16:34
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit 310ff65 into swiftlang:release/5.9 May 16, 2023
@hamishknight hamishknight deleted the off-the-chain-5.9 branch May 16, 2023 15:58
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 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants