Reputation: 5064
I'm trying to add an enum type to an Array and am getting an error. I am able to add a String and other types, but this enum is failing. Does anyone know what might be going wrong here?
enum Domain {
case Default
}
let domains: Array<Domain> = [.Default]
Thread 1:EXC_BAD_INSTRUCTION(code=EXC_i386_INVOP, subcode=0x0)
Upvotes: 3
Views: 2025
Reputation: 2843
This is definitely an Apple bug - log it! https://bugreport.apple.com
Add a second case to your Enumeration (e.g. case Other) and see that the error no longer occurs. Something crazy is going on in Swift when an Enumeration has only one case.
Upvotes: 3
Reputation: 4604
I think it's just a compiler bug on Apple's part... If I have the following code, and only this code, everything runs fine:
var points = TestEnum[]()
points += TestEnum.TestValue
enum TestEnum {
case TestValue
case SecondTestValue
}
However, I have code above that code (a simple RPN implementation, but it doesn't matter). The RPN code runs fine by itself. But with the TestEnum code in there, the RPN code crashes. The crash is an EXC_BAD_ACCESS and crashes on a random line and different address based on what lines of code are in the program (I'm guessing because the offsets in the executable change). For instance, I added a println after the points += call, and it crashed at a different part of my RPN code.
Both the RPN code and the TestEnum code run fine by themselves. This is almost definitely an Apple bug.
Upvotes: 0
Reputation: 746
It looks like, at least in my playing with a playground, if the enum definition contains the word 'Domain' at all anywhere in the name the enum fails to compile/work.
Upvotes: 0