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
SR-1535 No == overload exists for comparing optional arrays.
Issue Description:
1. If the switch statement's "value to be considered" is an optional and is being equated to other optionals, Swift will bridge the "value to be considered" to a _OptionalNilComparisonType, which cannot be equated to an optional of the same type.
letpet: String? = "dog"letdog: String? = "dog"letcat: String? = nil// Does not workswitchpet {
casedog:
print(dog)
casecat:
print(cat)
default:
print("did not match")
}
// Does workswitch () {
case_wherepet == dog:
print(dog)
case_wherepet == cat:
print(cat)
default:
print("did not match")
}
2. If the switch statement's "value to be considered" is not an optional but is being equated to optionals, the act of equating fails.
letpet: String = "dog"letdog: String? = "dog"letcat: String? = nil// Does not workswitchpet {
casedog:
print(dog)
casecat:
print(cat)
default:
print("did not match")
}
// Does workswitch () {
case_wherepet == dog:
print(dog)
case_wherepet == cat:
print(cat)
default:
print("did not match")
}
This is my first time posting here, I'm sorry if the formatting is off.
The text was updated successfully, but these errors were encountered:
The first problem should go away with conditional conformances, which will allow Optional to be Equatable when its element type is Equatable. The second one is correct behavior, I think, but at that point you'd be able to convert to the first by explicitly coercing to Optional in the argument to switch.
Environment
Xcode 8.0
OS X 10.11.6
Additional Detail from JIRA
md5: 81813b398f05d32291bc44dcd426803c
relates to:
Issue Description:
1. If the switch statement's "value to be considered" is an optional and is being equated to other optionals, Swift will bridge the "value to be considered" to a
_OptionalNilComparisonType
, which cannot be equated to an optional of the same type.2. If the switch statement's "value to be considered" is not an optional but is being equated to optionals, the act of equating fails.
This is my first time posting here, I'm sorry if the formatting is off.
The text was updated successfully, but these errors were encountered: