Created
August 17, 2015 19:34
-
-
Save NachoSoto/19499b0a52513c1671c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile with `swiftc switch.swift` | |
enum A { | |
case A(Int) | |
case B(Bool) | |
case C | |
case D | |
} | |
enum B { | |
case A | |
case B | |
} | |
func s(a: A, b: B) { | |
// error: switch must be exhaustive, consider adding a default clause | |
// WTF | |
switch (a, b) { | |
case let (.A(i), .A): | |
break | |
case let (.A(i), .B): | |
break | |
case let (.B(boolean), b): | |
break | |
case (.C, _), (.D, _): | |
break | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like it can’t infer
b
’s cases whena
is either.C
or.D
, only this works:Note: this was done in Swift 2.0 beta 5.