<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 Mar 7, 2016, at 1:44, Dennis Weissmann 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 class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">indeed the compiler should be able to infer the type here.</div></div></blockquote></div><br class=""><div class="">Swift very deliberately does <i class="">not</i> infer types across multiple statements in closure bodies. This is mostly an implementation restriction (our type-checking system can't handle it very well), but it's also a simple rule that <i class="">explains</i> the implementation restriction, rather than having type inference in closure bodies working some of the time but not all.</div><div class=""><br class=""></div><div class="">As Chris pointed out, the compiler could definitely do a better job communicating the problem, but actually <i class="">changing the behavior</i> here would require significant implementation work. So this is not considered a "bug", just an implementation-driven design choice.</div><div class=""><br class=""></div><div class="">Jordan</div></body></html>