Skip to content

Fix issue with expression patterns in switch exhaustivity checking #23804

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 1 commit into from
Apr 5, 2019

Conversation

jrose-apple
Copy link
Contributor

Expression patterns (and cast patterns) don't actually contribute to the exhaustivity of a switch statement—if you're matching against a String, matching "abc" doesn't meaningfully reduce the full space of the values you have to match. This was already handled, but didn't do the right thing in a particular case involving a tuple payload in an enum after the Space Engine (exhaustivity checker) optimizations that went out in Swift 5.

SR-10301 / rdar://problem/49609445

@jrose-apple jrose-apple requested review from davidungar and CodaFi April 4, 2019 23:06
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@@ -1448,6 +1449,8 @@ namespace {
}
} else if (SP->getKind() == PatternKind::Tuple) {
Space argTupleSpace = projectPattern(TC, SP);
if (argTupleSpace.isEmpty())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short comment here please.

Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jrose-apple
Copy link
Contributor Author

jrose-apple commented Apr 5, 2019

Same source compat failures seen elsewhere. @rintaro (current Apple build czar), do we have bugs tracking these?

Expression patterns (and cast patterns) don't actually contribute to
the exhaustivity of a switch statement---if you're matching against a
String, matching "abc" doesn't meaningfully reduce the full space of
the values you have to match. This was already handled, but didn't do
the right thing in a particular case involving a tuple payload in an
enum after the Space Engine (exhaustivity checker) optimizations that
went out in Swift 5.

https://bugs.swift.org/browse/SR-10301
@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Apr 5, 2019

Yes. rdar://problem/49610988

@jrose-apple jrose-apple merged commit d36a739 into swiftlang:master Apr 5, 2019
@jrose-apple jrose-apple deleted the empty-calories branch April 5, 2019 16:15
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Apr 5, 2019
…wiftlang#23804)

Expression patterns (and cast patterns) don't actually contribute to
the exhaustivity of a switch statement---if you're matching against a
String, matching "abc" doesn't meaningfully reduce the full space of
the values you have to match. This was already handled, but didn't do
the right thing in a particular case involving a tuple payload in an
enum after the Space Engine (exhaustivity checker) optimizations that
went out in Swift 5.

https://bugs.swift.org/browse/SR-10301
(cherry picked from commit d36a739)
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.

3 participants