Skip to content

[6.0][Sema] Non-exhaustive switch statements are always an error in Swift 6. #73481

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 8, 2024

Conversation

hborla
Copy link
Member

@hborla hborla commented May 7, 2024

  • Explanation: As described in https://forums.swift.org/t/amendment-se-0192-handling-future-enum-cases/68321, the Language Steering Group amended SE-0192 to make non-exhaustive switch statements over non-frozen enums errors in the Swift 6 language mode. These diagnostics have been staged in as warnings in Swift 5 mode for several releases; this change makes those warnings errors in Swift 6 mode, and adds a new NonfrozenEnumExhaustivity upcoming feature flag to subsume the bespoke -enable-nonfrozen-enum-exhaustivity-diagnostics which enables the diagnostics as warnings in the Swift 4 and 4.2 language modes.
  • Scope: Only impacts non-exhaustive switch statements over non-frozen enums in the Swift 6 language mode.
  • Risk: Low; only impacts the Swift 6 language mode.
  • Testing: Added new tests.
  • Main branch PR: [Sema] Non-exhaustive switch statements are always an error in Swift 6. #73472

hborla added 2 commits May 7, 2024 09:04
…with an

upcoming feature.

The bespoke flag still works as a way to enable the `NonfrozenEnumExhaustivity`
upcoming feature. `NonfrozenEnumExhaustivity` is enabled by default in the
Swift 6 language mode as errors, and enabled by default in the Swift 5 language
mode as warnings.

(cherry picked from commit a7920ce)
@hborla hborla requested a review from a team as a code owner May 7, 2024 16:08
@hborla
Copy link
Member Author

hborla commented May 7, 2024

@swift-ci please test

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