<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. After all, you supplied a ()rethrows->(Int) to it as its second argument, which is wrapping a ()throws->Int, “bFunction()"</div><div class="">?? and && 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. 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 value = try 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 value = try aFunction() ?? (try 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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=""> aFunction() -> </span><span style="font-family: Courier;" class="">Int</span><span style="font-family: Courier;" class="">? </span><span style="font-family: Courier;" class=""> </span><span style="font-family: Courier;" class="">{ </span><span style="font-family: Courier;" class="">return</span><span style="font-family: Courier;" class=""> </span><span style="font-family: Courier;" class="">5 }</span></div><div class=""><font face="Courier" class="">func bFunction() throws -> Int { return 4 }</font></div><div class=""><br class=""></div><div class=""><font face="Courier" class="">let value = aFunction() ?? try 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 value = try aFunction() ?? 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>