"Switch must be exhaustive" for tuple enums

When switching on an enumeration, if you write the switch without putting any cases, Xcode will complain that the "Switch must be exhaustive". If you click the error, it gives you the option of fixing it, and in doing so autocompleting the cases for you.

However, this doesn't work when switching on a tuple of enumerations. The same error will be displayed, but when clicking fix it, this is what will result:

enum Color {
    case red, blue
}
enum Number {
    case one, two
}
let tuple=(Color.red, Number.one)
switch tuple {
case (_, _):
}

What I'm proposing is that when clicking fix it for tuple enumerations this results:

switch tuple {
case (.red, .one):
case (.red, .two):
case (.blue, .one):
case (.blue, .two):
}
8 Likes

That would be a nice enhancement, I think. Diagnostics improvements like this don’t require approval through the Evolution process and can be filed as issues on the GitHub repository. They’ll be triaged from there.

8 Likes