Skip to content

[5.3] Handle Boolean Patterns Matching Against Invalid Constructor Forms #32823

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
Jul 11, 2020

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jul 10, 2020

Cherry-pick of #32822

@CodaFi CodaFi requested a review from a team as a code owner July 10, 2020 20:44
@CodaFi CodaFi changed the title Handle Boolean Patterns Matching Against Invalid Constructor Forms [5.3] Handle Boolean Patterns Matching Against Invalid Constructor Forms Jul 10, 2020
@CodaFi CodaFi requested a review from nathawes July 10, 2020 20:45
@CodaFi
Copy link
Contributor Author

CodaFi commented Jul 10, 2020

@swift-ci test

The Space Engine maintains as one of its invariants that the AST it is
handed must at least typecheck. When swift typechecks patterns, the only
case one is allowed to form a Boolean pattern is when a literal is
expected, and the corresponding type of the pattern clause is exactly
Bool. This precludes the use of other types, including
ExpressibleByBooleanLiteral types, from matching. Thus, this code path
was never hit. That is, until we accidentally lifted the restriction on
enum case base name overloading too early. Now, it is possible for the
space engine to see the same constructor head that has subspaces with
different argument types. The space engine is relatively tolerant of
this bizarre situation, but in this one narrow case it was not.

This patch has a narrow fix to add the missing case to the
space engine. In the long term, we need to actually finish SE-0155 which
will make this crash structurally impossible once again.

Resolves rdar://65229620
@CodaFi CodaFi force-pushed the enhanced-spacial-reasoning branch from 12e9dfb to 02dca7e Compare July 10, 2020 21:25
@CodaFi
Copy link
Contributor Author

CodaFi commented Jul 10, 2020

@swift-ci test

@swiftlang swiftlang deleted a comment from swift-ci Jul 10, 2020
@DougGregor DougGregor merged commit 1945310 into swiftlang:release/5.3 Jul 11, 2020
@CodaFi CodaFi deleted the enhanced-spacial-reasoning branch July 11, 2020 06:20
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
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.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants