<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="">Howdy,<div class="">The error message is not saying that aFunction throws, it says “??" might throw. &nbsp;After all, you supplied a ()rethrows-&gt;(Int) to it as its second argument, which is wrapping a ()throws-&gt;Int, “bFunction()"</div><div class="">?? and &amp;&amp; and || wrap the trailing expression in an @autoclosure.</div><div class=""><div class=""><br class=""></div><div class="">I am a little surprised two “try” are not required. &nbsp;This would be my expectation:</div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><font face="Courier" class="">let&nbsp;value = try&nbsp;aFunction() ?? try bFunction()</font></div></blockquote></div></blockquote><div class="">but, using try to the right of a non-assignment operator is not allowed.</div><div class=""><br class=""></div>This, however, is not disallowed:</div><div class=""><br class=""></div><div class="">let&nbsp;value =&nbsp;try&nbsp;aFunction() ?? (try&nbsp;bFunction())</div><div class=""><div class=""><br class=""></div><div class="">The purpose of the @autoclosure is to make developers forget they need to write a closure, and it apparently worked for you.</div><div class=""><br class=""></div><div class="">-Ben Spratling</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 11, 2016, at 1:16 AM, Karl via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">You might expect this code to work:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><span style="font-family: Courier;" class="">func</span><span style="font-family: Courier;" class="">&nbsp;aFunction() -&gt;&nbsp;</span><span style="font-family: Courier;" class="">Int</span><span style="font-family: Courier;" class="">?&nbsp;</span><span style="font-family: Courier;" class="">&nbsp; &nbsp; &nbsp;&nbsp;</span><span style="font-family: Courier;" class="">{&nbsp;</span><span style="font-family: Courier;" class="">return</span><span style="font-family: Courier;" class="">&nbsp;</span><span style="font-family: Courier;" class="">5&nbsp;}</span></div><div class=""><font face="Courier" class="">func&nbsp;bFunction()&nbsp;throws&nbsp;-&gt;&nbsp;Int&nbsp;{&nbsp;return&nbsp;4&nbsp;}</font></div><div class=""><br class=""></div><div class=""><font face="Courier" class="">let&nbsp;value =&nbsp;aFunction() ??&nbsp;try&nbsp;bFunction() // ERROR: Operator can throw but expression is not marked with a ‘try'</font></div><div class=""><font face="Courier" class="">print(value)</font></div></blockquote><div class=""><br class=""></div><div class="">Instead, you must put the ‘try’ before the entire expression:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Courier" class="">let&nbsp;value = try&nbsp;aFunction() ??&nbsp;bFunction()</font></div></blockquote><div class=""><br class=""></div><div class="">This is awkward, since aFunction() doesn’t throw.</div><div class="">I propose we change the grammar to allow the first example and disallow the second, consistent with the idea that throwing calls are ‘marked’ by using the try keyword.<br class=""><br class=""></div><div class="">Karl</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>