-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add compatibility tests for implicit (un)tupling in patterns. #26397
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
Add compatibility tests for implicit (un)tupling in patterns. #26397
Conversation
@swift-ci please smoke test |
test/Sema/exhaustive_switch.swift
Outdated
case tpair((Int, Int)) | ||
} | ||
|
||
func sr11212_content_tupled_pattern_untupled(t: Tupled) -> (Int, Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we already have test cases for the other two forms?
Can you add test cases for the generic one you've been working on, even if they don't work yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand which test cases you're referring to in "other two forms" and "generic one"? The table has 4 entries for code which shouldn't compile but still do (on master) -- I've added one function for each such entry. The SR-11160 fix fails two of those tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right: there should be 12 functions here: all four forms on all three kinds of enum (Untupled, Tupled, and Generic).
@swift-ci please smoke test |
So, hang on, if these all already work, what's different about SR-11160? |
Good point! Case 1
compiles fine but the supposedly equivalent code Case 2
does not. The reason this is happening is because the pattern decomposition is incorrect (this is the 3-line fix around
On master, there is another bug (which I just found out during this investigation), where projecting In Case 1, the two bugs cancel out as the overall operation becomes
In Case 2, the pattern that gets formed for When we try to subtract that from |
Oh wow, so SR-11160 really is specific to the Optional sugar syntax, even if accidentally. Okay, thanks for the explanation, and this looks good to merge! |
No wonder we didn't catch it earlier. |
I think the SR-11160 PR is actually introducing another error because it is allowing illegal subtractions instead of fixing the wrong pattern projection. Investigating that right now. |
Now I understand, thanks! |
Resolves SR-11212. See the issue description on JIRA for an explanation behind the test cases.