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
When you have a switch statement that switches on a tuple of enum values, and a pattern of _ is used for a tuple value, depending on its position, the compiler will identify the switch as not being exhaustive, when it is.
Example:
enumState {
casedisabled// No rowscaseawaiting// Input rowcasefinished// Input row + feedback row
}
funcupdateForState(oldoldState: State, newnewState: State) {
switch (oldState, newState) {
case (.disabled, .disabled), (.awaiting, .awaiting), (.finished, .finished):
print("Do nothing")
case (.disabled, _): // Compiler thinks the switch isn't exhaustive// case (.disabled, .awaiting), (.disabled, .finished): // If this case is used instead, compiler is happy.print("Reload whole section")
case (_, .disabled):
print("Reload whole section")
case (.awaiting, .finished):
print("Insert feedback row")
case (.finished, .awaiting):
print("Remove feedback row")
}
}
Playground attached to demostrate.
The text was updated successfully, but these errors were encountered:
Attachment: Download
Environment
Xcode 8.3.2
Swift 3.1
Additional Detail from JIRA
md5: 454f3ff04e415555a39c7e1fb36c87d9
Issue Description:
When you have a switch statement that switches on a tuple of enum values, and a pattern of
_
is used for a tuple value, depending on its position, the compiler will identify the switch as not being exhaustive, when it is.Example:
Playground attached to demostrate.
The text was updated successfully, but these errors were encountered: