Open jckarter opened 4 years ago
@swift-ci create
If to use optional associated values and matching to nil without label there will not be warnings or errors, but result will be unpredictable for programmer:
enum Enum {
case value(b: Bool?)
case value(s: String?)
}
func check(_ e: Enum) {
switch e {
case .value(nil):
print("\(e): associated value is nil")
default:
print("\(e): associated value is not nil")
}
}
check(.value(s: nil)) // printed: value(s: nil): associated value is nil
check(.value(b: nil)) // printed: value(b: nil): associated value is not nil
Tested in XCode 12.0.1 with default keychain. For development snapshot 2020-09-23 will be assertion failure "ambiguity in enum case name lookup?!"
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 2 | |Component/s | Compiler | |Labels | Sub-task | |Assignee | None | |Priority | Medium | md5: 350d59c094ebd69b46ed0ffb8988f306Parent-Task:
is blocked by:
duplicates:
Issue Description:
This crashes the compiler in an assertions-enabled build:
Without assertions enabled, it emits a bogus diagnostic:
The same assertion trips if you try to match only on pattern binding name:
or if the cases differ in arity, not only in label names: