Skip to content

Using value pack in closure crashes compiler #67503

@jasonbobier

Description

@jasonbobier

This code crashes the compiler:

struct SyncedTypes<T1, T2> {
	let properties: [(T1, inout T2) -> Void]
	
	init<each V: Equatable>(_ pair: repeat (KeyPath<T1, each V>, WritableKeyPath<T2, each V>)) {
		var properties = [(T1, inout T2) -> Void]()

		repeat properties.append( { (source: T1, destination: inout T2) in
			destination[keyPath: each pair.1] = source[keyPath: each pair.0]
		})

		self.properties = properties
	}
}

Environment

Xcode: Version 15.0 beta 4 (15A5195m)

Deployment target: iOS 17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.closuresFeature: closurescompilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsgenericsFeature: generic declarations and typespack expansionsFeature → expressions: Pack expansion expressionsparameter packsFeature → generics: Parameter packsswift 5.9type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions