Swift2 Xcode7b2 switch statements fail when using certain enumerations
| Originator: | ryancumley | ||
| Number: | rdar://21580939 | Date Originated: | Jun-27-2015 |
| Status: | Open | Resolved: | |
| Product: | Xcode 7b2 | Product Version: | |
| Classification: | Reproducible: | Always |
Ryan Cumley27-Jun-2015 04:15 PM
Summary:
'switch' statements fail to compile in Xcode 7b2 when switching off of a particular enum: namely an enumeration which has at least one member with an associated type of Array<SomeOtherType> and other members with no associated type.
A few examples of problem enumerations:
enum LiftingAnInt {
case One
case Two(Array<Int>)
case Three
}
protocol Test { }
enum LiftingAProtocol {
case One
case Two(Array<Test>)
case Three
}
Steps to Reproduce:
1. Compile with Xcode 6.3.2 (6D2105) No errors.
2. Compile with Xcode 7b2 (7A121l) Will fail to compile with error: "Terminator found in the middle of a basic block! label %entry LLVM ERROR: broken function found, compilation aborted!"
protocol Test { }
struct TestInstance: Test { }
enum ProblemExample {
case One
case Two(Array<Test>)
case Three
}
func someProblemExampleMember() -> ProblemExample {
return ProblemExample.Two([TestInstance()])
}
func forkProblemExecution() -> Int {
switch someProblemExampleMember() {
case .One: return 1
case .Two(let data):
print(data)
return 2
case .Three: return 3
}
}
Expected Results:
Expected Xcode7b2 (7A121l) to compile without errors, because Xcode 6.3.2 (6D2105) compiles without errors.
Actual Results:
No warnings are observed on the .swift file itself.
The build fails.
The 'CompileSwiftSources' step fails.
Compiling the actual file in question succeeds (green check mark) but throws an error: "Terminator found in the middle of a basic block! label %entry LLVM ERROR: broken function found, compilation aborted!"
Version:
Xcode 6.3.2/6D2105 & OS X 10.10.3/14D136 Compiles with no errors as expected
Xcode 7/7A121l & OS X 10.10.3/14D136 Build Fails to compile
Notes:
Interestingly enough, reducing the enum to consist only of members with the exact same associated type succeeds.
For example, these compile just fine in Xcode7b2
enum WorksJustFine {
case One(Array<Test>)
case Two(Array<Test>)
}
enum ThisCompilesFineToo {
case One(Array<Test>)
case Two(Array<Int>)
}
So my best debugging guess at this point would be that adding in an enumeration member with no associated values is where I'd start.
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!
Still reproducible in Xcode 7 beta 3 (7A152u)