# \[Accepted\] SE-0326: Multi-statement closure parameter/result type inference

**URL:** <https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502>\
**Category:** Announcements\
**Created:** [November 15, 2021, 4:06pm UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502 "2021-11-15T16:06:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-cohen](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ben-cohen/32/296_2.png) [@ben-cohen](https://forums.swift.org/u/ben-cohen)\
**Post date:** [November 15, 2021, 4:06pm UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/1 "2021-11-15T16:06:59Z")

</div>

Hello Swift Community,

The [review](https://forums.swift.org/t/se-0326-multi-statement-closure-parameter-result-type-inference/) of [SE-0326: Multi-statement closure parameter/result type inference](https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md) has completed. Feedback was light but positive, and the core team has **accepted** this proposal.

The core team recognizes that the language change has the slight possibility of requiring source changes, but that the benefits brought by this change merit including it without waiting for a language variant. In a test on a very large corpus of Swift source, only 1 instance of source code needing to be updated was found. The team would be interested in any feedback regarding more frequent source breaks from this change during release convergence.

Thank you to everyone who participated in the review!

Ben Cohen  
Review Manager

---

<div class="post-metadata">

**Author:** ![Nickolas\_Pohilets](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nickolas_pohilets/32/10659_2.png) [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Post date:** [November 15, 2021, 4:33pm UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/2 "2021-11-15T16:33:26Z")

</div>

Is there any data on how removal of the explicit signature affects performance of closure type-checking?

Type-checking SwiftUI code is an existing pain point for us. We use `-warn-long-expression-type-checking=1000` + `-warnings-as-errors` to prevent developers from creating loo large SwiftUI expressions, but due to the non-deterministic nature of the warning, even if it compiles normally on local machine, it may randomly fail on CI or on someone else's machine.

---

<div class="post-metadata">

**Author:** ![xedin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xedin/32/309_2.png) [@xedin](https://forums.swift.org/u/xedin)\
**Post date:** [November 15, 2021, 8:45pm UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/3 "2021-11-15T20:45:24Z")

</div>

It shouldn't affect type-checking time for the multi-statement closures significantly by itself but there is a possibility that removal of the type could affect some of the "complex" expressions that are replying on explicit parameter types to be solved efficiently. Also note that these changes do not affect type-checking of SwiftUI bodies because such bodies have special type-checking semantics.

---

<div class="post-metadata">

**Author:** ![Lantua](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lantua/32/8868_2.png) [@Lantua](https://forums.swift.org/u/Lantua)\
**Post date:** [November 16, 2021, 8:04pm UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/4 "2021-11-16T20:04:20Z")

</div>

> [@xedin](#):
>
> note that these changes do not affect type-checking of SwiftUI bodies because such bodies have special type-checking semantics.

Is this SwiftUI-specific, or does it apply to result builders in general?

---

<div class="post-metadata">

**Author:** ![hborla](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hborla/32/27563_2.png) [@hborla](https://forums.swift.org/u/hborla)\
**Post date:** [November 16, 2021, 8:21pm UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/5 "2021-11-16T20:21:16Z")

</div>

Result builders in general. This proposal does not affect result builders, because they are already type checked as a "single expression" in the constraint system. However, the implementation of SE-0326 introduces a new incremental statement type checking mechanism that we hope improves the performance of type checking result builders once they're ported to the new infrastructure.

---

<div class="post-metadata">

**Author:** ![xedin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xedin/32/309_2.png) [@xedin](https://forums.swift.org/u/xedin)\
**Post date:** [November 16, 2021, 8:23pm UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/6 "2021-11-16T20:23:17Z")

</div>

Sorry for the confusion, I should have mentioned that it's result builders in general and not just SwiftUI.

---

<div class="post-metadata">

**Author:** ![StevenSorial](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/stevensorial/32/8285_2.png) [@StevenSorial](https://forums.swift.org/u/StevenSorial)\
**Post date:** [February 19, 2022, 11:51am UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/7 "2022-02-19T11:51:47Z")

</div>

What is the status of this feature? I don't see it in version 5.6 or 5.7 sections in the [CHANGELOG](https://github.com/apple/swift/blob/main/CHANGELOG.md)

---

<div class="post-metadata">

**Author:** ![xedin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xedin/32/309_2.png) [@xedin](https://forums.swift.org/u/xedin)\
**Post date:** [February 23, 2022, 8:43am UTC](https://forums.swift.org/t/accepted-se-0326-multi-statement-closure-parameter-result-type-inference/53502/8 "2022-02-23T08:43:19Z")

</div>

The feature is available under the flag still. There are some performance problems related to operator chaining that need to be addressed before it could be enabled by default.
