<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi – I think you’re hitting a bug that was fixed recently. There was a missing default for this particular combination’s slice type, which then interacted quite unpleasantly with a compiler bug to cause a crash. Can you try it with the latest Xcode beta?<div class=""><br class=""></div><div class="">In the mean-time, adding the following to your declaration of your DynamicList ought to do as a workaround:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">typealias</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> SubSequence = </span><span style="font-variant-ligatures: no-common-ligatures" class="">MutableRangeReplaceableBidirectionalSlice</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures" class="">DynamicList</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">></span></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Mar 10, 2017, at 3:32 PM, Don Giovanni via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">The following code generates a segmentation error:<br class=""><br class=""><br class=""> extension Int<br class=""> {<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>static prefix func++(i:Int)->Int{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return i+1;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>static prefix func--(i:Int)->Int{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return i-1;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> }<br class=""><br class=""><br class=""> infix operator <-;<br class=""><br class=""> class DynamicList<T>: RangeReplaceableCollection, MutableCollection, BidirectionalCollection<br class=""> {<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>var length:Int;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>var arr:Array<T>?;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>var startIndex:Int{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return 0;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>var endIndex:Int{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return length;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>subscript(i:Int)->T{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>get{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return arr![i];<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>set{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>arr![i] = newValue;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>func index(after i: Int) -> Int{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return ++i;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>func index(before i: Int) -> Int{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return --i;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>required init(){<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>length = 0;<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>static func <- (left: inout DynamicList<T>, right: DynamicList<T>){<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>/* func replaceSubrange<C>(_ subrange: Range<Self.Index>, with newElements: C) where C : Collection,<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>C.Iterator.Element == Iterator.Element */<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>func replaceSubrange<C>(_ subrange: Range<DynamicList.Index>, with c: C)<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>where C : Collection, C.Iterator.Element == DynamicList.Iterator.Element{<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> <span class="Apple-tab-span" style="white-space:pre">        </span><br class=""> }<br class=""><br class="">My intent here is to have the generic class `DynamicList<T>`<br class=""><br class="">adopt three protocols: <br class=""><br class="">`class DynamicList<T>: RangeReplaceableCollection, MutableCollection, BidirectionalCollection` <br class=""><br class="">as indicated in the code above but it generates segmentation error. <br class=""><br class="">However, when I replace `MutableCollection` with `Collection`, code above complies. <br class=""><br class="">If I remove `BidirectionalCollection`, the code above compiles with no segmentation error. <br class=""><br class="">Is it not possible to adopt all 3: <br class=""><br class="">- RangeReplaceableCollection <br class="">- MutableCollection <br class="">- BidirectionalCollection <br class=""><br class="">at the same time? Thanks.<br class=""><br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></div></blockquote></div><br class=""></div></div></div></body></html>