Compiler Segmentation Fault While Using Set in Swift

Compiler segmentation fault while using Set in Swift

A better, more idiomatic way to construct your lineSet is simply:

let lineSet: Set = ["one", "one", "two"] 

Hope this fixes your compiler crash. Unfortunately, I was unable to fully reproduce your original issue, so I can't really confirm my fix will be any different ;)

As already mentioned, deleting your DerivedData folder is a good idea (also ~/Library/Caches/com.apple.dt.Xcode might help as well). A somewhat standard practice when Xcode starts behaving erratically.

Segmentation fault: 11 with swift

The problem is this bit of code:

@IBAction func one(_ sender: AnyObject) {
defaults.set(1, forKey: "Sphere")
print("Ghost one was selected")
}

You've found a compiler bug. Try to work around it like this:

@IBAction func one(_ sender: AnyObject) {
defaults.set(1 as Any, forKey: "Sphere")
print("Ghost one was selected")
}

You will need to do that for all your defaults.set calls. I think that will allow you to compile.

Segmentation Fault in Swift

Update

Thanks to a comment from @MartinR it turns out that a even better solution is to implement replaceSubrange(_:with:) from the RangeReplaceableCollection protocol instead of append

mutating func replaceSubrange<C>(_ subrange: Range<Int>, with newElements: C) where C : Collection, MyEnum == C.Element {
self.enums.replaceSubrange(subrange, with: newElements)
}

Old solution

You need to implement append() as well

public mutating func append(_ newElement: MyEnum) {
enums.append(newElement)
}

There is a default implementation of this function but of course it has no knowledge about your internal data source enums so it is not usable.


Going forward you might also need to implement other functions that has a default implementation.

Another thing, personally I would use the properties of the Array class as well when conforming to the protocol.

public var startIndex: Int {
return enums.startIndex
}

public var endIndex: Int {
return self.enums.endIndex
}

Xcode 9.0 segmentation fault 11 while type-checking Codable in Swift

There is a struct and a constant named def. Rename one to avoid ambiguity.

Segmentation fault in Swift compiler when converting to Swift 4 syntax Ask

Automatic syntax converter go trough once I apply another warning "apply recommended settings", it changed swift module optimization.

OS X Swift Compiler Error - Segmentation Fault

Ok - I have now been able to compile the code without an error with the properties declared at the top of the Class.

The issue was the use of the short form declaration relying on the type of item being inferred.

let propertyName: Set = ["item1", "item2"]

when I initialised the property using the following syntax

let propertyName: Set<String> = ["item1", "item2"]

it compiled without an error. The short form declaration worked when the property was declared within a function.



Related Topics



Leave a reply



Submit