Skip to content

Command SwiftCompile failed with a nonzero exit code (View + Parameter Pack) #68919

Open
@twhitt14

Description

@twhitt14

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfgenericsFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsswift 5.9

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions