[swift-users] Compiler can't infer map transfer closure return type?

Jordan Rose jordan_rose at apple.com
Mon Mar 7 15:33:58 CST 2016

> On Mar 7, 2016, at 1:44, Dennis Weissmann via swift-users <swift-users at swift.org> wrote:
> indeed the compiler should be able to infer the type here.

Swift very deliberately does not 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 explains the implementation restriction, rather than having type inference in closure bodies working some of the time but not all.

As Chris pointed out, the compiler could definitely do a better job communicating the problem, but actually changing the behavior here would require significant implementation work. So this is not considered a "bug", just an implementation-driven design choice.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160307/9bea383d/attachment.html>

More information about the swift-users mailing list