You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Swift 5.2 (Xcode 11.4), there appears to be a new warning:
"Cannot match several associated values at once, implicitly tupling the associated values and trying to match that instead."
This is the behavior I want, and it's unclear what the problem is. Swift is doing exactly the right thing, but warning about it without indicating what problem it's fixing or how I should resolve the issue.
Given that the default behavior seems to be exactly as desired, this warning needs to explain why I should write so much highly-fragile code instead, or the warning should be removed and the this behavior codified as correct.
The text was updated successfully, but these errors were encountered:
This might be related to SR-11212, but reading the defect, I still don't understand the problem this warning is trying to prevent. (But it's not clear this is the same issue, since the whole point here is that I'm not splatting the tuple.)
> I still don't understand the problem this warning is trying to prevent.
The problem with the old behavior is that (1) it cannot be made to work consistently in the presence of nested patterns (a user ran into this in SR-11160) and (2) it is an oversight in SE-0110, patterns should behave analogous to function arguments – there is a difference between an enum case which has 1 associated value which is a tuple of N elements and an enum case which has N associated values.
> Given that the default behavior seems to be exactly as desired, this warning needs to explain why I should write so much highly-fragile code instead
I agree that for this particular case, the behavior is convenient and there is not much that can go wrong.
However in the general case, the old behavior makes it unpredictable what should/should not work. The table in SR-11212 shows four cases where the compiler's behavior was not what one would predict before the fix.
Marking this as resolved for now (since we have improved the warning), but please feel free to unresolve it if you feel like something is unclear or you feel that this should not be a warning (in the latter case, maybe we can have a discussion on the Swift forum or somewhere else).
Additional Detail from JIRA
md5: 04f75c69b330cde1c9919a42bdfde1ca
Issue Description:
In Swift 5.2 (Xcode 11.4), there appears to be a new warning:
"Cannot match several associated values at once, implicitly tupling the associated values and trying to match that instead."
This is the behavior I want, and it's unclear what the problem is. Swift is doing exactly the right thing, but warning about it without indicating what problem it's fixing or how I should resolve the issue.
Specifically I have a line of code:
Where
.loading
is defined asThe warning seems to suggest this is the correct way to write it:
Given that the default behavior seems to be exactly as desired, this warning needs to explain why I should write so much highly-fragile code instead, or the warning should be removed and the this behavior codified as correct.
The text was updated successfully, but these errors were encountered: