<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 14, 2016, at 2:05 PM, Toni Suter 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="">Hi,<div class=""><br class=""></div><div class="">I would have expected that the following code reports an error, because</div><div class="">of ambiguous function overloads:<br class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">infix operator ***: MultiplicationPrecedence</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">infix operator +++: AdditionPrecedence</font></div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><font face="Courier New" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">func ***(x: Int, y: Int) -> String {</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f1")</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return ""</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">}</font></div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><font face="Courier New" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">func ***(x: Int, y: Int) -> Int {</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f2")</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return 0</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">}</font></div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><font face="Courier New" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">func +++(x: String, y: Int) -> Int {</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f3")</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return 0</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">}</font></div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><font face="Courier New" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">func +++(x: Int, y: Int) -> Int {</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print("f4")</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return 0</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">}</font></div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><font face="Courier New" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Courier New" class="">let result = 0 *** 4 +++ 0<span class="Apple-tab-span" style="white-space:pre">                </span>// prints f2 and f4</font></div></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">As far as I can tell, there are two possible overload resolutions: f1 + f3 or f2 + f4.</div><div class="">I thought that these two solutions get an "equivalent score" and therefore there would</div><div class="">be a compile error. However, that's not the case. Instead, the type checker picks</div><div class="">f2 and f4.</div><div class=""><br class=""></div><div class="">So, I guess my question is, whether there is some rule, that prefers</div><div class="">operators, which have the same argument types and the same return type</div><div class="">or whether this is simply a bug.</div></div></div></blockquote><div><br class=""></div><div>It’s a bug, and one that I’m aware of, but I’m not aware of anything in JIRA for it. Do you mind opening an issue there and assigning it to me?</div><div><br class=""></div><div>Mark</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Thanks and best regards,</div><div class="">Toni</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=""></body></html>