Segmentation error appears while serializing 'AnyArrayBox'
Here is the AnyArray struct
struct AnyArray<Element>: RandomAccessCollection {
typealias Index = Int
private let box: AnyArrayBase<Element>
init<Concrete: RandomAccessCollection>(_ concrete: Concrete) where Concrete.Element == Element, Concrete.Indices == Indices {
box = AnyArrayBox(concrete)
}
var startIndex: Int { return box.startIndex }
var endIndex: Int { return box.endIndex }
func index(after i: Int) -> Int {
return box.index(after: i)
}
subscript(position: Index) -> Element {
return box[position]
}
}
And two others which is used in there
private class AnyArrayBase<Element>: RandomAccessCollection {
init() {
guard type(of: self) != AnyArrayBase.self else {
fatalError("_AnyArrayBase<Element> is an abstract class, it can not be created; create subclass instance instead")
}
}
typealias Index = Int
var startIndex: Int { fatalError("Must override") }
var endIndex: Int { fatalError("Must override") }
func index(after i: Int) -> Int {
fatalError("Must override")
}
subscript(position: Index) -> Element {
fatalError("Must override")
}
}
private final class AnyArrayBox<Concrete: RandomAccessCollection>: AnyArrayBase<Concrete.Element> where Concrete.Indices == AnyArrayBase<Concrete.Element>.Indices {
private let concrete: Concrete
init(_ concrete: Concrete) {
self.concrete = concrete
}
override var startIndex: Int { return concrete.startIndex }
override var endIndex: Int { return concrete.endIndex }
override func index(after i: Int) -> Int {
return concrete.index(after: i)
}
override subscript(position: Index) -> Element {
return concrete[position]
}
}
How can I fix it? Any recommendations?
this works
var dim_values : (dim1:String?,dim2:String?,dim3:String?) = (nil, nil, nil)
apparently the compiler needs an explicit initialization (to nil)