<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></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 Oct 9, 2016, at 5:07 PM, Jean-Denis Muys 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=""><div dir="ltr" class="">Here is a contrived reduction of my problem<br class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> mainFunction(closure:(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">Int</span><span style="font-variant-ligatures:no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> closureDoubled(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">_</span><span style="font-variant-ligatures:no-common-ligatures" class=""> n: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">Int</span><span style="font-variant-ligatures:no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> result = closure(n)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">return</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="">2</span><span style="font-variant-ligatures:no-common-ligatures" class="">*result</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> temp1 = closure(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="">1</span><span style="font-variant-ligatures:no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> temp2 = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="">closureDoubled</span><span style="font-variant-ligatures:no-common-ligatures" class="">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="">1</span><span style="font-variant-ligatures:no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">return</span><span style="font-variant-ligatures:no-common-ligatures" class=""> temp1+temp2</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class="">The line "<span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="">let</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures" class=""> result = closure(n)</span>" is refused by the compiler with the error message "declaration over non closing parameter may allow it to escape".</div><div class=""><br class=""></div><div class="">First off, while I know what an escaping or a non-escaping closure is, I find this error message utterly impossible to understand. To begin with, the sentence "non closing parameter" is meaningless to me.</div><div class=""><br class=""></div><div class="">In any case, my main function is passed a non-escaping closure. I want to call it from inside it, the compiler is ok with. I want also to call it from a nested function, but the compiler disagrees.</div><div class=""><br class=""></div><div class="">I believe the compiler should not complain here. Did I miss anything?</div></div></div></blockquote><br class=""></div><div>I agrre that the compiler should be able to determine that the closure is nonescaping in this case, and that that diagnostic is in dire need of revision. Would you be able to file a couple of bug reports, one to allow this example, and one to improve the error message?</div><div><br class=""></div><div>-Joe</div><br class=""></body></html>