This code crashes ("Unexpectedly found nil while unwrapping an Optional value")
It does not crash if I use
To me this looks like a bug in Swift's constructor code, but maybe I am overlooking something?
Code Block import Combine class Receiver { var value: Int! var cancellables = Set<AnyCancellable>([]) init(_ p: AnyPublisher<Int,Never>) { p.assign(to: \.value, on: self).store(in: &cancellables) } } let receiver = Receiver(Just(5).eraseToAnyPublisher())
It does not crash if I use
Code Block p.sink { self.value = $0 }.store(in: &cancellables)
instead of the assign, and it does not crash if I do not use an optional for the value-property.To me this looks like a bug in Swift's constructor code, but maybe I am overlooking something?