[swift-users] Crash in generic struct

Jan E. Schotsman jeschot at xs4all.nl
Wed May 4 09:41:30 CDT 2016


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>]()
	}

extension MyHeap
	{
	init( withElements elements:[MyHeapElement<T>] )
		{
		self.elements = elements
		}
	}

Do I have a syntax error somewhere or is this a compiler bug (apart  
from that ideally the compiler should never crash)?

Swift 2.1-2.2

Jan E.


More information about the swift-users mailing list