[6.4] Runtime Crash from SwiftUI parameter packs

I would really like some help to bring this runtime crash over the finish line and hopefully find a fix. Anyone that can help triage or debug can please comment here or on the tasks.

This SwiftUI app will instacrash when built from Xcode 27:

import SwiftUI

struct Input<T> {
  init(_ input: T) { }
}

struct Repeater<each T> {
  @State private var storage = Storage()

  private var input: (repeat Input<each T>)

  init(_ input: repeat each T) {
    self.input = (repeat Input(each input))
  }
}

extension Repeater {
  final class Storage {
    
  }
}

@main
struct CrashDemoApp: App {
  private var repeater = Repeater(1)
  
  var body: some Scene {
    WindowGroup {
      EmptyView()
    }
  }
}

This app did not crash from Xcode 26.

Here is a repro without SwiftUI:

FWIW I can repro the crash from 5.10. This has been here for a long time. It only looks like a "new" crash from SwiftUI because State was refactored to include new types that I assume are resilient… hence the runtime crash when building from Xcode 27.

Here is a repro from CI:

Here is a task with some more information:

Here is a fix for what could be an adjacent crash:

What is interesting here is this fix actually did fix an earlier version of this crash. I then found a new version of the crash after I added an extra layer of indirection.

1 Like