Skip to content
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

[SR-8197] REGRESSION: Switch exhaustiveness handles Never separately from other no-valued types #50729

Closed
lilyball mannequin opened this issue Jul 6, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Jul 6, 2018

Previous ID SR-8197
Radar None
Original Reporter @lilyball
Type Bug
Status Closed
Resolution Duplicate
Environment

Apple Swift version 4.2 (swiftlang-1000.0.25.1 clang-1000.10.28.1)
Target: x86_64-apple-darwin17.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression
Assignee None
Priority Medium

md5: 8dac1ec8317572716c99c92e1f1dd897

duplicates:

  • SR-8125 Swift 4.2 exhaustivity checker regression

Issue Description:

In Swift 4.1, Swift's switch exhaustiveness checker is happy to let you skip handling cases that cannot be constructed (because they involve a type with no values). Swift 4.2 has a regression where it only lets you skip the case if the type involved is Never but does not let you skip the case anymore if the type is some other no-valued type.

Reproduction:

enum MyNever {}

enum Foo<T,U> {
    case one(T)
    case two(U)
    case three
}

func foo(_ foo: Foo<Int,MyNever>) {
    switch foo {
    case .one(let x): print(x)
    // skip two, the value is Never
    case .three: print("three!")
    }
}

This compiles just fine in Swift 4.1 but fails in Swift 4.2 with the error

unnamed.swift:10:5: error: switch must be exhaustive
    switch foo {
    ^
unnamed.swift:10:5: note: add missing case: '.two(_)'
    switch foo {
    ^
@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Jul 6, 2018

This appears to be a duplicate of SR-8125.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2
Projects
None yet
Development

No branches or pull requests

1 participant