<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=""> </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=""> </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=""> </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=""> </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 <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> 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> and attached a playground. Any workaround magic I can do here?<div class=""><div class=""><br class=""></div><div class="">func quickSort<Element: Comparable>(_ input: [Element]) -> [Element] {</div><div class=""> if input.count < 2 {<br class=""> return input<br class=""> }<br class=""> let pivot = input.first!<br class=""> let left = input.dropFirst().filter { $0 <= pivot }<br class=""> let right = input.dropFirst().filter { $0 > pivot }<br class=""><br class=""> // Does not compile with (Swift 3pre) Xcode 8 b1,2,3,4<br class=""> // Does compile with (Swift 2.2) Xcode 7.3<br class=""> return quickSort(left) + [pivot] + 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 convert value of type '[Element]' to expected argument type '[_]'<br class="">//return quickSort(left) + [pivot] + quickSort(right)<br class="">// ^~~~</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>