|
|
| Previous ID |
SR-2293 |
| Radar |
None |
| Original Reporter |
loic (JIRA User) |
| Type |
Bug |
| Status |
Resolved |
| Resolution |
Done |
Environment
Swift Development Snapshot 2016-08-04
Additional Detail from JIRA
|
|
| Votes |
0 |
| Component/s |
Compiler |
| Labels |
Bug |
| Assignee |
@CodaFi |
| Priority |
Medium |
md5: 3527892211bcbd8b2b306ab21047581f
Issue Description:
It might be useful to use uninhabited types in enums, for example:
enum NeverError: Error { }
enum Result <T, E: Error> {
case success(T)
case failure(E)
}
typealias GuaranteedResult<T> = Result<T, NeverError>
However, the compiler will not correctly consider the case failure as unreachable
func foo(result: GuaranteedResult<Int>) {
switch result {
case .success(let x): …
case .failure(let n): … // should warn that this code is unreachable
}
}
An exhaustive switch for GuaranteedResult should only consist of one case:
switch result {
case .success(let x): …
}
// switch should be considered exhaustive
Environment
Swift Development Snapshot 2016-08-04
Additional Detail from JIRA
md5: 3527892211bcbd8b2b306ab21047581f
Issue Description:
It might be useful to use uninhabited types in enums, for example:
However, the compiler will not correctly consider the case
failureas unreachableAn exhaustive switch for GuaranteedResult should only consist of one case: