indirect enum and if case

The following works as expected:

indirect enum List {
    case Empty
    case Value(Int, List)
}
let n = List.Value(123, List.Value(456, List.Empty))

switch n {
case .Empty: print("empty")
case let .Value(v, _): print("value: \(v)")
}


(Printing "value: 123")


But using an "if case" instead of the switch will crash the compiler:

indirect enum List {
    case Empty
    case Value(Int, List)
}
let n = List.Value(123, List.Value(456, List.Empty))

if case let .Value(v, _) = n {
    print(v)
}


(Xcode 7 beta 4, OS X 10.10.4)


Anyone know of a workaround that will let me use if case with indirect enums without crashing the compiler, or do I have to write switches instead until this is fixed?

Accepted Reply

This is a known bug in beta 4 - it will be fixed in a later beta. You should write switches until the fix rolls out.


-Chris

Replies

This is a known bug in beta 4 - it will be fixed in a later beta. You should write switches until the fix rolls out.


-Chris