<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 Apr 26, 2016, at 12:15 AM, Aleksandar Petrovic 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=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">Hi Swift community, I have a question.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">This is a valid Swift code:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><div id="bloop_customfont" style="margin: 0px;" class="">func testFunc(times: Int, fn: ((Int)-&gt;Void)? = nil) {</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>guard let f = fn else { return }</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>for i in 1 ..&lt; times {</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>f(i)</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</div><div id="bloop_customfont" style="margin: 0px;" class="">}</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class="">And this is not:</div><div id="bloop_customfont" style="margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="margin: 0px;" class=""><div id="bloop_customfont" style="margin: 0px;" class="">func testFunc(times: Int, @noescape fn: ((Int)-&gt;Void)? = nil) {</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>guard let f = fn else { return }</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>for i in 1 ..&lt; times {</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>f(i)</div><div id="bloop_customfont" style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</div><div id="bloop_customfont" style="margin: 0px;" class="">}</div><div class=""><br class=""></div><div class="">I can't think of any hard reason why the @noescape parameter of the function can't be nullable (and, with default value, be optional), but maybe I'm missing something. Is there any plan to correct this in 3.0?</div></div></div></div></blockquote><br class=""></div><div>There are two ways to fix this: a horrible hack that special cases optionals, or the more principled solution that treats optional as the underlying enum type that it is, and making @noescape propagate through to the members of the .some case.</div><div><br class=""></div><div>You can probably guess this, but I’d prefer to discuss fixing the full generality of the problem, not providing a special case in the compiler for this.</div><div><br class=""></div><div>-Chris</div><br class=""></body></html>