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-4890] Exhaustive switch not treated as exhaustive #47467

Closed
swift-ci opened this issue May 15, 2017 · 4 comments
Closed

[SR-4890] Exhaustive switch not treated as exhaustive #47467

swift-ci opened this issue May 15, 2017 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-4890
Radar rdar://problem/32201580
Original Reporter erica (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 1
Component/s
Labels Bug
Assignee erica (JIRA)
Priority Medium

md5: 71f266f40374f7cab9067ecfa09da645

duplicates:

  • SR-483 Exhaustivity checking for switch statement with wildcards doesn't work properly

Issue Description:

func f(x: Int?, y: Int?) {
    switch (x, y) {
    case (let x?, _):
        _ = x // use x
    case (_, let y?):
        _ = y // use y
    case (nil, nil): //  switch must be exhaustive, consider adding a default clause
        break
    }
}

The above errors but the following correctly catches that the 3d case won't ever execute:

func f(x: Int?, y: Int?) {
    switch (x, y) {
    case (let x?, _):
        _ = x
    case (_, let y?):
        _ = y
    case (let x?, let y?): // case will never be executed
        _ = x
        _ = y
    case (nil, nil):
        break
    }
}
@jckarter
Copy link
Member

Still repros in master. CodaFi (JIRA User), does your Space Engine not understand nil as .none on optionals?

@jckarter
Copy link
Member

@swift-ci create

@CodaFi
Copy link
Member

CodaFi commented May 15, 2017

It does understand that, and I can't get it to reproduce.

@jckarter
Copy link
Member

Ah, sorry, you're right. I had copied and pasted the unformatted example, and the other cases where commented out since it was all on one line.

@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.
Projects
None yet
Development

No branches or pull requests

3 participants