Switching on a tuple made of boolean members of a struct results in a compiler error
| Originator: | SlaunchaMan | ||
| Number: | rdar://18945658 | Date Originated: | 11/11/2014 |
| Status: | Duplicate/16514545 | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.1 |
| Classification: | Other Bug | Reproducible: | Always |
Summary: Even though the attached switch statement covers every logical possibility for the switch statement, Xcode complains that the switch statement is not exhaustive and should contain a default case. Steps to Reproduce: 1. Create a struct in Swift with two or more boolean values. 2. Create an instance of the struct, initialized with values. 3. Create a tuple of two of the boolean values in the struct. 4. Switch on the tuple with (true, true), (true, false), (false, true), and (false, false) covered. Expected Results: Because all four possible truth states are covered, the compiler will not complain about a missing default statement. Actual Results: “Switch must be exhaustive, consider adding a default clause.” Version: Xcode 6.1 from the Mac App Store
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
The attachment is this code in a Playground:
struct SomeBools { var a: Bool var b: Bool var c: Bool }
let example = SomeBools(a: false, b: false, c: false)
var tupleOfBools = (example.a, example.b)
switch (tupleOfBools) { case (true, true), (false, false): println("they were the same") case (false, true), (true, false): println("they were not the same") }