-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Check for let vs var bindings of the same variable name in multiple case patterns #15488
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
Conversation
@swift-ci Please smoke test and merge. |
Not sure why the checks never reported back status, so try this again: |
@@ -2920,6 +2920,9 @@ ERROR(fallthrough_into_case_with_var_binding,none, | |||
ERROR(unnecessary_cast_over_optionset,none, | |||
"unnecessary cast over raw value of %0", (Type)) | |||
|
|||
ERROR(mutability_mismatch_multiple_pattern_list,none, | |||
"pattern variable is '%select{var|let}0', " |
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.
Nit: phrasing.
[var/let] pattern binding must match previous [var/let] pattern binding
@shahmishal Hi! Any suggestions on how to unstick swift-ci here? |
@swift-ci Please smoke test and merge |
Looking into why its not triggering for you |
@shahmishal Sure thing! I think when I first asked swift-ci (5 days ago) it was during a period when the CI servers were hung, and maybe there's something cached somewhere that tests for this pull are already "in progress"? |
(It's probably a thing where I could just close this and re-make a new pull, so if it's not useful for debugging swift-ci feel free to tell me to just do that.) |
Try again, looking at logs. |
@swift-ci Please smoke test and merge |
@gregomni Thanks!! |
@shahmishal Thank you! |
// Would be nice to have a fixit in the following line if we detect that all bindings in the same pattern have the same problem. | ||
case let (a, b) where a < 5, var (a, b) where a > 10: // expected-error 2{{'var' pattern binding must match previous 'let' pattern binding}}{{none}} | ||
break | ||
case (let a, var b) where a < 5, (let a, let b) where a > 10: // expected-error {{'let' pattern binding must match previous 'var' pattern binding}}{{44-47=var}} |
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.
Can you add a test case with three patterns?
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.
@jrose-apple Ah, good call, with three patterns and two wrong, invalidating the first pattern variable when comparing with the 2nd caused a spurious diagnostic about the type of the 3rd not matching error-type. Fixed now!
@swift-ci Please smoke test and merge |
@gregomni We have seen issue with force push, where GitHub sha does dont get updated. I recommend asking again if you dont see results with in 2mins. |
@swift-ci Please smoke test and merge |
Resolves SR-7261 | rdar://problem/38800528 .