Drop the extension and move the initializer to the MyHeap struct and it
compiles for me on Swift 3.0. To me that indicates the answer to your
first question: I would think you do not have a syntax error. That is:
struct MyHeapElement <T:Comparable> {
var index: Int
var key: T
}
struct MyHeap <T:Comparable> {
var elements = [MyHeapElement<T>]()
init(withElements elements: [MyHeapElement<T>]) {
self.elements = elements
}
}
Regardless of whether it is or not you should file the bug at
bugs.swift.org. As you say the compiler should never crash.
···
On Wed, May 4, 2016, at 10:41 AM, Jan E. Schotsman via swift-users wrote:
Hello,
This code causes a segmentation fault:
struct MyHeapElement<T:Comparable>
{
var index:Int
var key:T
}
struct MyHeap<T:Comparable>
{
var elements = [MyHeapElement<T>]()
}
Drop the extension and move the initializer to the MyHeap struct and it
compiles for me on Swift 3.0. To me that indicates the answer to your
first question: I would think you do not have a syntax error. That is:
struct MyHeapElement <T:Comparable> {
var index: Int
var key: T
}
struct MyHeap <T:Comparable> {
var elements = [MyHeapElement<T>]()
init(withElements elements: [MyHeapElement<T>]) {
self.elements = elements
}
}
Regardless of whether it is or not you should file the bug at
bugs.swift.org. As you say the compiler should never crash.
That number looks like a radar issue. Swift bugs typically take the form
SR-#.
I don't work at Apple (nor do many people on this mailing list).
Therefore we cannot see the contents of that bug report.
Once again I suggest you file an issue at bugs.swift.org as that is the
OSS community tracker.
As for losing the default initializer; I understand that may occur. I
was pointing out that it was my simple way of validating the syntax. It
may or may not work as a "work-around". It would appear it does not for
you.