<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=""><b class="">@David</b><div class="">If you would split up the statement like this...</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">let x = 0 *** 4</font></div><div class=""><font face="Courier New" class="">let result = x +++ 0</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class="">... the compiler would report an ambiguity error, because both overloads of *** are valid and of equivalent priority.</div><div class="">You could do something like this though:</div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">let x: Int = 0 *** 4<span class="Apple-tab-span" style="white-space:pre">        </span>// picks f2</font></div><div class=""><font face="Courier New" class="">let result = x +++ 0<span class="Apple-tab-span" style="white-space:pre">        </span>// picks f4</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class="">or this:</div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><div class=""><font face="Courier New" class="">let x: String = 0 *** 4<span class="Apple-tab-span" style="white-space: pre;">        </span>// picks f1</font></div><div class=""><font face="Courier New" class="">let result = x +++ 0<span class="Apple-tab-span" style="white-space: pre;">        </span>// picks f3</font></div></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class="">Now the compiler has enough type information to know which overload to pick.</div><div class=""><br class=""></div><div class=""><b class="">@Mark</b></div><div class="">Ok, thanks. I reported a bug at <a href="https://bugs.swift.org/browse/SR-3209" class="">https://bugs.swift.org/browse/SR-3209</a> and assigned it to you.</div><div class=""><br class=""></div><div class=""><b class="">@Rien</b></div><div class="">Yes, it is even possible to use the operators as the example above shows, but it is requires a bit more explicit</div><div class="">type information so that the type checker knows which overload to pick.</div><div class=""><br class=""></div><div class="">Thanks and best regards,</div><div class="">Toni</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Am 15.11.2016 um 08:41 schrieb Rien <<a href="mailto:Rien@Balancingrock.nl" class="">Rien@Balancingrock.nl</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class="">I seem to remember that while it is possible to define, the compiler will yield an error if you try to use the functions (“cannot resolve”).<br class=""><br class="">Regards,<br class="">Rien<br class=""><br class="">Site: <a href="http://balancingrock.nl" class="">http://balancingrock.nl</a><br class="">Blog: <a href="http://swiftrien.blogspot.com" class="">http://swiftrien.blogspot.com</a><br class="">Github: <a href="http://github.com/Swiftrien" class="">http://github.com/Swiftrien</a><br class="">Project: <a href="http://swiftfire.nl" class="">http://swiftfire.nl</a><br class=""><br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On 14 Nov 2016, at 23:05, Toni Suter via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:<br class=""><br class="">Hi,<br class=""><br class="">I would have expected that the following code reports an error, because<br class="">of ambiguous function overloads:<br class=""><br class="">infix operator ***: MultiplicationPrecedence<br class="">infix operator +++: AdditionPrecedence<br class=""><br class="">func ***(x: Int, y: Int) -> String {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f1")<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return ""<br class="">}<br class=""><br class="">func ***(x: Int, y: Int) -> Int {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f2")<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return 0<br class="">}<br class=""><br class="">func +++(x: String, y: Int) -> Int {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f3")<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return 0<br class="">}<br class=""><br class="">func +++(x: Int, y: Int) -> Int {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f4")<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return 0<br class="">}<br class=""><br class="">let result = 0 *** 4 +++ 0<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>// prints f2 and f4<br class=""><br class=""><br class="">As far as I can tell, there are two possible overload resolutions: f1 + f3 or f2 + f4.<br class="">I thought that these two solutions get an "equivalent score" and therefore there would<br class="">be a compile error. However, that's not the case. Instead, the type checker picks<br class="">f2 and f4.<br class=""><br class="">So, I guess my question is, whether there is some rule, that prefers<br class="">operators, which have the same argument types and the same return type<br class="">or whether this is simply a bug.<br class=""><br class="">Thanks and best regards,<br class="">Toni<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=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></body></html>