Open
Description
Description
The code below looks like it should compile but does not.
Steps to reproduce
Add the following code to a project:
import SwiftUI
struct BindingProvider<each T, Content: View>: View {
@State private var state: (repeat State<each T>)
private var content: ((repeat Binding<each T>)) -> Content
init(_ initialState: repeat each T,
@ViewBuilder content: @escaping ((repeat Binding< each T>)) -> Content)
{
self.content = content
self._state = State(initialValue: (repeat State(initialValue: each initialState)))
}
var body: Content {
content((repeat (each state).projectedValue))
}
}
Expected behavior
The code should compile or give a meaningful error.
Environment
- Swift compiler version info: swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
- Xcode version info: Xcode 15.0 Build version 15A240d
- Deployment target: iOS 17.0
Additional context
More info on the purpose of the code in quesion - https://stackoverflow.com/questions/77101028/how-to-use-swift-parameter-packs-in-a-view