[swift-users] Crash in generic struct
Jan E. Schotsman
jeschot at xs4all.nl
Wed May 4 12:20:05 CDT 2016
On May 4, 2016, at 5:02 PM, Ryan Lovelett wrote:
> 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 way I lose the memberwise initializer and the default initializer.
This is yet another crashing bug related to the position of an
extension.
In December I reported this bug which looks similar:
bug 23998571
If the struct definition and the extension are placed in two different
files of a framework project the compiler crashes.
struct Description
{
var property:Int32 = 0
}
extension Description
{
init( startPtr: UnsafePointer<Int32> )
{
property = startPtr[0]
}
}
Still open, still crashing.
Jan E.
More information about the swift-users
mailing list