ResultBuilder, buildPartialBlock, reducing and buildArray

This ugly hunk of type erasing code gets the exact same error


struct Tuple2AnyLayer: Layer, RenderableLayer {
    var id:String { "Tuple" }
    var first: any Layer
    var second: any Layer
    
    init<L0:Layer, L1:Layer>(first:L0, second:L1) {
        self.first = first
        self.second = second
    }
    
    func render() {
        first._render()
        second._render()
    }
}

extension LayerBuilder {
    static func buildArray<L:Layer>(_ components: [L]) ->  some Layer {
        if components.count < 3 {
            fatalError("Gotta be more than 3 for now.")
        }
        let start = Tuple2AnyLayer(first:Tuple2AnyLayer(first: components[0], second: components[1]), second: components[2])
        let theRest = components.suffix(components.count-3)
        
        if theRest.isEmpty {
            return start
        }
        
        return theRest.reduce(start, {Tuple2AnyLayer(first: $0, second: $1)})
    }
}


let singularType = Assembly {
    Square()
    for _ in 0...3 {
        Circle() 
    }//ERROR HERE
    Square()
}

Related? - Improved Result Builder Implementation in Swift 5.8 - #15 by dispatchqueue