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
Name lookup in switch statements seems buggy. I'll demonstrate the issue with a few examples, showing issues ranging from bad diagnostics to what I consider to be bugs:
enumA { caseone }
enumB { caseone }
lete = A.oneswitche {
caseA.one: print("one")
caseB.one: print("one") // error: Enum case 'one' is not a member of type 'A'
}
enumA { caseone }
lete: A? = A.oneswitche {
caseA.one: print("one") // error: Enum case 'one' is not a member of type 'A?'
}
structS {
vari: Intstaticvarten: S { returnS(i: 10)}
}
lets: S? = .tenswitchs {
case .ten: print("ten") // error: enum case 'ten' not found in type 'S?'default: print("default")
}
Mirroring my response from the forum post: The diagnostics are bad, but this is not a bug. Optional upcasting and other implicit conversions are not a feature of pattern matching, so you have to spell out .some or ?.
Environment
Xcode Version 9.3.1 (9E501)
Additional Detail from JIRA
md5: 975f95ad72ab1feb8da2706157ab7a00
Issue Description:
Name lookup in switch statements seems buggy. I'll demonstrate the issue with a few examples, showing issues ranging from bad diagnostics to what I consider to be bugs:
You can see more examples and some discussion in this forum thread.
The text was updated successfully, but these errors were encountered: