<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="">Looks like a bug in the type inference system to me, but I’ll let someone with a better knowledge of the compiler confirm. Meanwhile, you can work around by explicitly casting any of the pieces of the return statement to `[Element]` or using a temporary for one or more of them.<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> middle = [pivot]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">quickSort</span><span style="font-variant-ligatures: no-common-ligatures" class="">(left) + middle + </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">quickSort</span><span style="font-variant-ligatures: no-common-ligatures" class="">(right)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">quickSort</span><span style="font-variant-ligatures: no-common-ligatures" class="">(left) </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">as</span><span style="font-variant-ligatures: no-common-ligatures" class=""> [</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Element</span><span style="font-variant-ligatures: no-common-ligatures" class="">] + [pivot] + </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">quickSort</span><span style="font-variant-ligatures: no-common-ligatures" class="">(right)</span></div><div class=""><br class=""></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">quickSort</span><span style="font-variant-ligatures: no-common-ligatures" class="">(left) + ([pivot] </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">as</span><span style="font-variant-ligatures: no-common-ligatures" class=""> [</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Element</span><span style="font-variant-ligatures: no-common-ligatures" class="">]) + </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">quickSort</span><span style="font-variant-ligatures: no-common-ligatures" class="">(right)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></span></div><div><blockquote type="cite" class=""><div class="">On Aug 4, 2016, at 9:02 AM, Ray Fix via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div>I filed <a href="rdar://27700622" class="">rdar://27700622</a>&nbsp;and attached a playground. &nbsp;Any workaround magic I can do here?<div class=""><div class=""><br class=""></div><div class="">func&nbsp;quickSort&lt;Element:&nbsp;Comparable&gt;(_&nbsp;input: [Element]) -&gt; [Element] {</div><div class="">&nbsp; &nbsp;&nbsp;if&nbsp;input.count&nbsp;&lt;&nbsp;2&nbsp;{<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;input<br class="">&nbsp; &nbsp;&nbsp;}<br class="">&nbsp; &nbsp;&nbsp;let&nbsp;pivot = input.first!<br class="">&nbsp; &nbsp;&nbsp;let&nbsp;left = input.dropFirst().filter&nbsp;{ $0&nbsp;&lt;=&nbsp;pivot }<br class="">&nbsp; &nbsp;&nbsp;let&nbsp;right = input.dropFirst().filter&nbsp;{ $0&nbsp;&gt;&nbsp;pivot }<br class=""><br class="">&nbsp; &nbsp;&nbsp;// Does not compile with (Swift 3pre) Xcode 8 b1,2,3,4<br class="">&nbsp; &nbsp;&nbsp;// Does compile with (Swift 2.2) Xcode 7.3<br class="">&nbsp; &nbsp;&nbsp;return&nbsp;quickSort(left) + [pivot] +&nbsp;quickSort(right)<br class="">}<br class=""><br class="">quickSort([3,5,1,2])</div><div class=""><br class=""></div><div class="">Error:</div><div class="">//Playground execution failed: error: quicksort.playground:11:22: error: cannot&nbsp;convert value of type '[Element]' to expected argument type '[_]'<br class="">//return quickSort(left) + [pivot] + quickSort(right)<br class="">//&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;^~~~</div></div><div class=""><br class=""></div><div class=""><br class=""></div></div>_______________________________________________<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></blockquote></div><br class=""></div></body></html>