swift
swift copied to clipboard
Cannot use `self.` with parameter packs
This code compiles:
class Store<State> {
var currentState: State { fatalError() }
}
class CompositeStore<CompositeState, each State, OriginalState>: Store<CompositeState> {
let store: (repeat Store<each State>)
let combine: ((repeat (each State)) -> CompositeState)
override var currentState: CompositeState {
return self.combine(repeat (each store).currentState)
}
init(store1: (repeat Store<each State>),
combine: @escaping (repeat (each State)) -> CompositeState)
{
self.store = store1
self.combine = combine
}
}
But if I use self.store instead:
return self.combine(repeat (each self.store).currentState)
I get this diagnostic:
/tmp/foo.swift:10:42: error: expected ',' separator
return self.combine(repeat (each self.store).currentState)
^
,
/tmp/foo.swift:10:37: error: cannot find 'each' in scope
return self.combine(repeat (each self.store).currentState)
^~~~
/tmp/foo.swift:10:29: error: value pack expansion must contain at least one pack reference
return self.combine(repeat (each self.store).currentState)
^
/tmp/foo.swift:10:54: error: value of tuple type '(_, (repeat Store<each State>))' has no member 'currentState'
return self.combine(repeat (each self.store).currentState)
~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~
error: fatalError
Steps to reproduce
xcrun --toolchain org.swift.59202306051a swiftc /tmp/foo.swift -Xfrontend -disable-availability-checking
Environment
- 6/5/23 main snapshot