# \#result-builder

**URL:** https://forums.swift.org/tag/result-builder/544.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [How to design result builders with multiple component types](https://forums.swift.org/t/how-to-design-result-builders-with-multiple-component-types/85640)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 2\
**Last updated:** [April 4, 2026, 5:42am UTC](https://forums.swift.org/t/how-to-design-result-builders-with-multiple-component-types/85640 "2026-04-04T05:42:13Z")

</div>

The usual result builder examples use only one component type. How can a builder with multiple component types work. Both when component types can be in any order, and when there are (partial) order restrictions. (Exampl…

---

## [Is it possible to use a result builder as part of another?](https://forums.swift.org/t/is-it-possible-to-use-a-result-builder-as-part-of-another/85191)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 0\
**Last updated:** [March 6, 2026, 7:18pm UTC](https://forums.swift.org/t/is-it-possible-to-use-a-result-builder-as-part-of-another/85191 "2026-03-06T19:18:29Z")

</div>

Let’s say I’m designing a type that will use a result builder. The format permits HTML-based documentation. Instead of adding a bunch of HTML-related build entries, could I use an existing HTML result builder? How would …

---

## [\`var\`-backed parameters passed in with \`@lValue\`, causing inefficient parameter packing](https://forums.swift.org/t/var-backed-parameters-passed-in-with-lvalue-causing-inefficient-parameter-packing/83642)

<div class="topic-metadata">

**Author:** [@Chris\_Williams](https://forums.swift.org/u/Chris_Williams)\
**Replies:** 11\
**Last updated:** [December 10, 2025, 9:47pm UTC](https://forums.swift.org/t/var-backed-parameters-passed-in-with-lvalue-causing-inefficient-parameter-packing/83642 "2025-12-10T21:47:01Z")

</div>

I go into this extensively in Issue #85924, but TL;DR... These two statements type-check differently: func merge\<each A, B\>(\_ a: (repeat each A), \_ b: B) -\> (repeat each A, B) { return (repeat each a, b) } // The …

---

## [Different result type using Parameter Packs in a result builder](https://forums.swift.org/t/different-result-type-using-parameter-packs-in-a-result-builder/78854)

<div class="topic-metadata">

**Author:** [@nickmain](https://forums.swift.org/u/nickmain)\
**Replies:** 5\
**Last updated:** [December 9, 2025, 10:24pm UTC](https://forums.swift.org/t/different-result-type-using-parameter-packs-in-a-result-builder/78854 "2025-12-09T22:24:53Z")

</div>

This tuple builder function returns a "flat" tuple (as I expect/hope): func appendTo\<each T, E\>(tuple: (repeat each T), element: E) -\> (repeat each T, String, E) { (repeat each tuple, "DIVIDER", element) } let firs…

---

## [Async marker shown for UIView properties in @resultBuilder DSL under Swift 6 strict concurrency](https://forums.swift.org/t/async-marker-shown-for-uiview-properties-in-resultbuilder-dsl-under-swift-6-strict-concurrency/82007)

<div class="topic-metadata">

**Author:** [@blazej.sleboda](https://forums.swift.org/u/blazej.sleboda)\
**Replies:** 12\
**Last updated:** [September 10, 2025, 1:24pm UTC](https://forums.swift.org/t/async-marker-shown-for-uiview-properties-in-resultbuilder-dsl-under-swift-6-strict-concurrency/82007 "2025-09-10T13:24:55Z")

</div>

I maintain a framework called Adobels/UIViewKit, which provides a DSL for configuring UIViews and their Auto Layout constraints using @resultBuilder, allowing views to be written in code instead of relying on Storyboards…

---

## [How do result builders handle if/else-if, without plain else, chains?](https://forums.swift.org/t/how-do-result-builders-handle-if-else-if-without-plain-else-chains/79344)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 0\
**Last updated:** [April 18, 2025, 1:05am UTC](https://forums.swift.org/t/how-do-result-builders-handle-if-else-if-without-plain-else-chains/79344 "2025-04-18T01:05:26Z")

</div>

As I understand it for Result Builders, a lone if statement maps to a build-optional an if-else pair maps to two build-either calls a switch maps to a tree of build-either calls an if/(else-if)/else chain also maps to …

---

## [What are we supposed to do if a result builder goes wrong?](https://forums.swift.org/t/what-are-we-supposed-to-do-if-a-result-builder-goes-wrong/79270)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 1\
**Last updated:** [April 15, 2025, 8:37pm UTC](https://forums.swift.org/t/what-are-we-supposed-to-do-if-a-result-builder-goes-wrong/79270 "2025-04-15T20:37:05Z")

</div>

All the example builders I’ve seen can take all combinations of build pieces. But what if that’s not the case? If I’m building a Dictionary, I’d want to flag when someone tries a key twice. I have seen no kind of error h…

---

## [Miniscript DSL implementation (how to simplify complex solution)](https://forums.swift.org/t/miniscript-dsl-implementation-how-to-simplify-complex-solution/78684)

<div class="topic-metadata">

**Author:** [@craigwrong](https://forums.swift.org/u/craigwrong)\
**Replies:** 1\
**Last updated:** [March 21, 2025, 11:02am UTC](https://forums.swift.org/t/miniscript-dsl-implementation-how-to-simplify-complex-solution/78684 "2025-03-21T11:02:15Z")

</div>

Hi! I'm working on a DSL for https://bitcoin.sipa.be/miniscript/ and ran into an issue trying to make expressions conform to different result types depending on their inputs. To abstract the problem I've come up with a…

---

## [Swift ResultBuilder Type Inference Issue](https://forums.swift.org/t/swift-resultbuilder-type-inference-issue/78329)

<div class="topic-metadata">

**Author:** [@Chenyungui](https://forums.swift.org/u/Chenyungui)\
**Replies:** 1\
**Last updated:** [March 6, 2025, 2:23pm UTC](https://forums.swift.org/t/swift-resultbuilder-type-inference-issue/78329 "2025-03-06T14:23:20Z")

</div>

Problem Description I'm encountering a type inference problem when using Swift's ResultBuilder pattern. In the code shown below, the compiler reports an error at the closure call to the build method: "Type of expression …

---

## [Associate result builders with types](https://forums.swift.org/t/associate-result-builders-with-types/77476)

<div class="topic-metadata">

**Author:** [@sveinhal](https://forums.swift.org/u/sveinhal)\
**Replies:** 5\
**Last updated:** [January 30, 2025, 8:15am UTC](https://forums.swift.org/t/associate-result-builders-with-types/77476 "2025-01-30T08:15:54Z")

</div>

Some types and protocols are strongly associated with a result builder (View and its @ViewBuilder from SwiftUI comes to mind, but there are several others). In a View conforming type you need to remember to decorate you…

---

## [ResultBuilder that does something in buildEither](https://forums.swift.org/t/resultbuilder-that-does-something-in-buildeither/76784)

<div class="topic-metadata">

**Author:** [@jemmons](https://forums.swift.org/u/jemmons)\
**Replies:** 1\
**Last updated:** [December 20, 2024, 6:46pm UTC](https://forums.swift.org/t/resultbuilder-that-does-something-in-buildeither/76784 "2024-12-20T18:46:28Z")

</div>

I (think) I understand why buildEither(first:) and buildEither(second:) are necessary to transform the body of a result builder into a tree that accurately represents the conditional logic of the source. But in practice …

---

## [resultBuilder debugging pain](https://forums.swift.org/t/resultbuilder-debugging-pain/76275)

<div class="topic-metadata">

**Author:** [@Hacksaw](https://forums.swift.org/u/Hacksaw)\
**Replies:** 2\
**Last updated:** [November 29, 2024, 9:05am UTC](https://forums.swift.org/t/resultbuilder-debugging-pain/76275 "2024-11-29T09:05:30Z")

</div>

In using resultBuilders, primarily ViewBuilder, my biggest pain point is that internal problems are obscured by type inference error messages. Instead of being told where things broke down, I just get told it can't figur…

---

## [PoC: Result Builder using Body Macro](https://forums.swift.org/t/poc-result-builder-using-body-macro/73008)

<div class="topic-metadata">

**Author:** [@mtsrodrigues](https://forums.swift.org/u/mtsrodrigues)\
**Replies:** 2\
**Last updated:** [July 14, 2024, 8:09pm UTC](https://forums.swift.org/t/poc-result-builder-using-body-macro/73008 "2024-07-14T20:09:55Z")

</div>

This weekend I decided to try implementing a result builder using the new function body macro and here I share my results: So, is it possible? Yes it is, but with a few limitations, specially regardless diagnostics. en…

---

## [Result Builder Virtual ASTs](https://forums.swift.org/t/result-builder-virtual-asts/72926)

<div class="topic-metadata">

**Author:** [@mtsrodrigues](https://forums.swift.org/u/mtsrodrigues)\
**Replies:** 1\
**Last updated:** [July 4, 2024, 3:42pm UTC](https://forums.swift.org/t/result-builder-virtual-asts/72926 "2024-07-04T15:42:22Z")

</div>

In my adventure with the swift compiler something that caught my attention and desire to implement is Virtualized Abstract Syntax Trees (ASTs) in future directions of result builder. I decided to try and I managed to su…

---

## [Testing for result builder errors](https://forums.swift.org/t/testing-for-result-builder-errors/69422)

<div class="topic-metadata">

**Author:** [@David\_Catmull](https://forums.swift.org/u/David_Catmull)\
**Replies:** 0\
**Last updated:** [January 13, 2024, 7:24pm UTC](https://forums.swift.org/t/testing-for-result-builder-errors/69422 "2024-01-13T19:24:13Z")

</div>

Apple has created a great setup for developing macros, including tests for expected errors. I'm wishing for a similar thing for result builders, since you can also have compile-time errors if the result builder isn't use…

---

## [Implementation of a DSL with inter-relationships](https://forums.swift.org/t/implementation-of-a-dsl-with-inter-relationships/69215)

<div class="topic-metadata">

**Author:** [@RapidZinc](https://forums.swift.org/u/RapidZinc)\
**Replies:** 10\
**Last updated:** [January 5, 2024, 12:23pm UTC](https://forums.swift.org/t/implementation-of-a-dsl-with-inter-relationships/69215 "2024-01-05T12:23:06Z")

</div>

I'm making a directory app, where the data will only be updated occasionally, but the dataset is complex and full of inter-relationships. To seed the data, I implemented a domain specific language, but I want to expand …

---

## [Result builder of variadic type](https://forums.swift.org/t/result-builder-of-variadic-type/69022)

<div class="topic-metadata">

**Author:** [@dehesa](https://forums.swift.org/u/dehesa)\
**Replies:** 0\
**Last updated:** [December 15, 2023, 10:17pm UTC](https://forums.swift.org/t/result-builder-of-variadic-type/69022 "2023-12-15T22:17:31Z")

</div>

Given a variadic type with a minimum of two elements, is it possible to create an instance of such type with a result builder? I have defined a ChoiceOf type (very similar to the one defined in the RegexBuilder module),…

---

## [Swift @resultBuilder with enum problem](https://forums.swift.org/t/swift-resultbuilder-with-enum-problem/67679)

<div class="topic-metadata">

**Author:** [@morecats](https://forums.swift.org/u/morecats)\
**Replies:** 4\
**Last updated:** [October 7, 2023, 11:29am UTC](https://forums.swift.org/t/swift-resultbuilder-with-enum-problem/67679 "2023-10-07T11:29:00Z")

</div>

I think i am having a problem using resultBuild with enums, is that normal or compile improve need? @resultBuilder struct ResultBuilder\<T\> { static func buildBlock(\_ block: \[T\]...) -\> \[T\] { block.flatMap…

---

## [ResultBuilder, buildPartialBlock, reducing and buildArray](https://forums.swift.org/t/resultbuilder-buildpartialblock-reducing-and-buildarray/66563)

<div class="topic-metadata">

**Author:** [@carlynorama](https://forums.swift.org/u/carlynorama)\
**Replies:** 19\
**Last updated:** [August 4, 2023, 5:46pm UTC](https://forums.swift.org/t/resultbuilder-buildpartialblock-reducing-and-buildarray/66563 "2023-08-04T17:46:49Z")

</div>

I'm trying to use the new syntax of resultBuilder to make something like a "ViewBuilder" but I'm having difficulty adding for loops. I have the protocol. I have the aggregating type. I have a working result builder, all…

---

## [Improved Result Builder Implementation in Swift 5.8](https://forums.swift.org/t/improved-result-builder-implementation-in-swift-5-8/63192)

<div class="topic-metadata">

**Author:** [@xedin](https://forums.swift.org/u/xedin)\
**Replies:** 19\
**Last updated:** [August 4, 2023, 7:53pm UTC](https://forums.swift.org/t/improved-result-builder-implementation-in-swift-5-8/63192 "2023-08-04T19:53:58Z")

</div>

I am happy to announce that the result builder implementation has been re-worked in Swift 5.8 to greatly improve compile-time performance, code completion results, and diagnostics. The new implementation is now enabled b…

---

## [Result Builder Optionals](https://forums.swift.org/t/result-builder-optionals/66549)

<div class="topic-metadata">

**Author:** [@BastianKusserow](https://forums.swift.org/u/BastianKusserow)\
**Replies:** 4\
**Last updated:** [August 3, 2023, 12:41pm UTC](https://forums.swift.org/t/result-builder-optionals/66549 "2023-08-03T12:41:55Z")

</div>

Hey there! I am currently struggling to find a way to create a result builder for the following. Lets say I have a type FooBar that consists of a string and an int like so: struct FooBar { var foo: String var bar:…

---

## [Result builder attributes in types](https://forums.swift.org/t/result-builder-attributes-in-types/66304)

<div class="topic-metadata">

**Author:** [@ellie20](https://forums.swift.org/u/ellie20)\
**Replies:** 0\
**Last updated:** [July 22, 2023, 7:56pm UTC](https://forums.swift.org/t/result-builder-attributes-in-types/66304 "2023-07-22T19:56:34Z")

</div>

Right now, result builder attributes can be added to protocol requirements, properties, and functions. This pitch allows result builder attributes to be added to types. For example, a hypothetical HTML type that comes wi…

---

## [Unwanted AnyView](https://forums.swift.org/t/unwanted-anyview/65081)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 5\
**Last updated:** [May 19, 2023, 3:15pm UTC](https://forums.swift.org/t/unwanted-anyview/65081 "2023-05-19T15:15:39Z")

</div>

I am experimenting with view caching. Note the use of type erased AnyView: class ViewCache { static let shared = ViewCache() private init() {} private var cache: \[AnyHashable: AnyView\] = \[:\] //😢 …

---

## [Result builder-annotated parameter does not contribute to a function's signature](https://forums.swift.org/t/result-builder-annotated-parameter-does-not-contribute-to-a-functions-signature/64895)

<div class="topic-metadata">

**Author:** [@Pat](https://forums.swift.org/u/Pat)\
**Replies:** 2\
**Last updated:** [May 9, 2023, 4:46pm UTC](https://forums.swift.org/t/result-builder-annotated-parameter-does-not-contribute-to-a-functions-signature/64895 "2023-05-09T16:46:46Z")

</div>

I have a fairly simple result builder that is generic over one type. When I try to create a generic function that uses a closure annotated with my result builder type, the Swift compiler tells me that the generic paramet…

---

## [resultBuilder buildOptional issue](https://forums.swift.org/t/resultbuilder-buildoptional-issue/62497)

<div class="topic-metadata">

**Author:** [@Kyle-Ye](https://forums.swift.org/u/Kyle-Ye)\
**Replies:** 6\
**Last updated:** [May 8, 2023, 5:39pm UTC](https://forums.swift.org/t/resultbuilder-buildoptional-issue/62497 "2023-05-08T17:39:31Z")

</div>

Normally, the following code cannot be compiled. let a = 3 if let b = a { // ❌Error: Initializer for conditional binding must have Optional type, not 'Int' ... } But if we define a resultBuilder and implement buildOpti…

---

## [\[Pitch\] Result builder scoped unqualified lookup](https://forums.swift.org/t/pitch-result-builder-scoped-unqualified-lookup/62190)

<div class="topic-metadata">

**Author:** [@angela-laar](https://forums.swift.org/u/angela-laar)\
**Replies:** 29\
**Last updated:** [January 7, 2023, 7:04am UTC](https://forums.swift.org/t/pitch-result-builder-scoped-unqualified-lookup/62190 "2023-01-07T07:04:13Z")

</div>

Hello Swift community, I have a pitch for you about adding new name lookup rules for result builders. Please share any thoughts or questions about this pitch! Special thanks to @xedin and @hborla for meaningful feedbac…

---

## [Result builders versus private types](https://forums.swift.org/t/result-builders-versus-private-types/61242)

<div class="topic-metadata">

**Author:** [@David\_Catmull](https://forums.swift.org/u/David_Catmull)\
**Replies:** 1\
**Last updated:** [November 4, 2022, 11:25pm UTC](https://forums.swift.org/t/result-builders-versus-private-types/61242 "2022-11-04T23:25:32Z")

</div>

I'm working on a result builder, and running into a problem where I'm having to make some of my implementation details public. Since a result builder essentially transforms the code in place, all types involved (eg those…

---

## [Troubleshooting result builders](https://forums.swift.org/t/troubleshooting-result-builders/60797)

<div class="topic-metadata">

**Author:** [@David\_Catmull](https://forums.swift.org/u/David_Catmull)\
**Replies:** 5\
**Last updated:** [November 2, 2022, 10:24am UTC](https://forums.swift.org/t/troubleshooting-result-builders/60797 "2022-11-02T10:24:10Z")

</div>

What techniques are there for figuring out errors with result builders? I'm working on a somewhat complex one using buildPartialBlock to enforce elements appearing in a certain order, and at the moment I'm having trouble…

---

## [SE-0373: Lift all limitations on variables in result builders](https://forums.swift.org/t/se-0373-lift-all-limitations-on-variables-in-result-builders/60592)

<div class="topic-metadata">

**Author:** [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Replies:** 23\
**Last updated:** [October 27, 2022, 2:39am UTC](https://forums.swift.org/t/se-0373-lift-all-limitations-on-variables-in-result-builders/60592 "2022-10-27T02:39:32Z")

</div>

Hello, Swift community. The review of SE-0373: Lift all limitations on variables in result builders begins now and runs through October 10th, 2022. Reviews are an important part of the Swift evolution process. All revi…

---

## [\[Accepted\] SE-0373: Lift all limitations on variables in result builders](https://forums.swift.org/t/accepted-se-0373-lift-all-limitations-on-variables-in-result-builders/61041)

<div class="topic-metadata">

**Author:** [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Replies:** 0\
**Last updated:** [October 26, 2022, 7:59pm UTC](https://forums.swift.org/t/accepted-se-0373-lift-all-limitations-on-variables-in-result-builders/61041 "2022-10-26T19:59:30Z")

</div>

Hello, all. The review of SE-0373: Lift all limitations on variables in result builders ran from September 30th to October 10th. The Language Workgroup kept the review open for an extra week or so to discuss some late-…

[Next page](https://forums.swift.org/tag/result-builder/544.md?match_all_tags=true&page=1&tags%5B%5D=result-builder)
