Closed jaanussiim closed 9 months ago
I have the same issue also.
Hi @jaanussiim, thank you very much for the simple reproducible example. That was very helpful.
I've been able to verify the crash, and I was able to reduce the example a little bit:
struct ParentView: View {
let store = Store(initialState: Parent.State()) {
Parent()
}
var body: some View {
Form {
IfLetStore(
store.scope(state: \.$child, action: \.child),
then: ChildView.init(store:),
else: {
Button(action: { store.send(.show) }) {
Text("Show")
}
}
)
}
}
}
@Reducer
struct Parent {
struct State {
@PresentationState var child: Child.State?
}
enum Action {
case child(PresentationAction<Child.Action>)
case show
}
var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .child(.presented(.dismiss)):
state.child = nil
return .none
case .child:
return .none
case .show:
state.child = Child.State()
return .none
}
}
.ifLet(\.$child, action: \.child) {
Child()
}
}
}
struct ChildView: View {
let store: StoreOf<Child>
var body: some View {
Button("Dismiss") { store.send(.dismiss) }
}
}
@Reducer
struct Child {
struct State {}
enum Action { case dismiss }
var body: some ReducerOf<Self> { EmptyReducer() }
}
I've got a fix for the crash, but want to get some tests into place and want to discuss with Stephen too. For now I suggest pinning to 1.5.1 to avoid the problem.
@larryonoff @jaanussiim Can y'all try pointing to this branch and see if it fixes the problem for you?
https://github.com/pointfreeco/swift-composable-architecture/compare/store-cache-crash-fix
The location where I found the crash is no longer crashing when using branch store-cache-crash-fix
@mbrandonw thanks for the fix! The crash flew away.
Description
Noticed a crash when upgrading from 1.5.1 to 1.5.2
Checklist
main
branch of this package.Expected behavior
No response
Actual behavior
No response
Steps to reproduce
The Composable Architecture version information
1.5.2
Destination operating system
iOS17
Xcode version information
Version 15.1 (15C65)
Swift Compiler version information