Adding a (convenient) computed height
property to UIView
in my UIViewExtension.swift
file is causing the Swift compiler to segfault...
This error happens also if you accidentally declare a variable with a type matching its name:
var sectionGroup: sectionGroup? { ... }
Xcode 8.2.
Adding @nonobjc
protocol implementation into extension causing segmentation faults.
Move @nonobjc
protocol implementation into class implementation.
Seems like the Swift 2 compiler might not have been quite ready for prime-time! In case this helps anyone, I was getting a segmentation fault: 11 due to a mismatch with the variable type in a closure header, specifically in a Parse method, PFQuery.query.findObjectsInBackgroundWithBlock
.
You can see the issue in more detail here: https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/280
In my case the culprit was accidentally overloading a function expecting an array argument with one with a variadic argument:
public required init(_ args: Node...) {
}
When the superclass had it defined as an array:
public required init(_ args: [Node]) {
}
This typically happens when the compiler does not have enough information (despite what you think) to guarantee/determine the state of a statement or a variable within a statement.
For example, imagine you have a dictionary of type [String: String] which you populate with city names as keys and a comma separated list of corresponding zip codes/post codes.
Imagine that somewhere in your code you want to update the list of corresponding codes:
myDict[town] += newZipCode + ","
In this case, the compiler will respond with segmentation fault as town
might not be in the dictionary and therefore it cannot guarantee that the above statement will have a valid value.
To resolve this, you should store the current state of myDict[town]
in a separate variable allowing you to handle the case of key not in dict
and then update the value for the given key:
myDict[town] = guaranteedValue + "," newZipCode + ","
Unfortunately, it is not always straightforward to determine the root cause so I hope this simple example helps.
I had this error because I was doing this :
if(currentMeal?.State == .Deleted){
}
instead of
if(currentMeal!.State == .Deleted){
}
so I think optional not unwrapped in if condition can cause this error