Skip to content

[5.9] [SILGen] Emit block after unreachable when emitting if/switch expressions #66571

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

Conversation

hamishknight
Copy link
Contributor

5.9 cherry-pick of #66551

  • Explanation: Fixes an issue where a switch expression over an uninhabited subject would crash the compiler.
  • Scope: Affects switch expressions with uninhabited subjects (i.e Never)
  • Radar: rdar://110636210
  • Risk: Low, only affects switch expressions over uninhabited subjects
  • Testing: Added tests to test suite
  • Reviewer: @eeckstein

…ions

When emitting the underlying `switch` statement
for a `switch` expression, we emit an `unreachable`
if the subject is uninhabited. Statement emission
code can handle this, but expression emission expects
an RValue to handed back. To remedy this, emit
an unreachable block that we can emit the rest of
the expression emission code into. The SILOptimizer
will then drop this unreachable block.
@hamishknight hamishknight added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels Jun 12, 2023
@hamishknight hamishknight requested a review from a team as a code owner June 12, 2023 18:55
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit 467c0d0 into swiftlang:release/5.9 Jun 13, 2023
@hamishknight hamishknight deleted the never-say-never-5.9 branch June 13, 2023 13:38
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