Reputation: 3753
The attached screen shot says it all: I have a valid true Bool, I negate it with the bang operator, and (Xcode tells me) I have an invalid value.
It appears that this "invalid" value does behave as if it were false. But really, wtf?
Upvotes: 11
Views: 1159
Reputation: 5166
Got the same issue, with correct value for add code like print(theBoolValue)
.
But when use p
in swift command line. Or just check the value in debug stack, the value become <invalid>(Oxfe)
.
Upvotes: 0
Reputation: 48085
I've had this issue in Xcode 8.3.1 and Swift 3.1 https://github.com/onmyway133/notes/issues/278
I tried
But does not work. The workaround is to
let enabled = disable ? false : true
Upvotes: 1
Reputation: 2715
I'm no LLVM expert but I wouldn't be surprised about this behavior at all, unless optimization is set to Onone
in which case it should have left your code alone. The intermediate variable is just asking to be optimized away, after all.
Upvotes: 0