Skip to content

Commit c6b0a6c

Browse files
Fix archiving problem since 1.4.0 (#2641)
* Fix BindingReducer.swift After discussion with Jon Shier (@jshier) on the Slack, he suggested making this change. It appears to fix the key path getter error that was appearing when trying to archive a project using the BindingReducer. I've tested a project which compiled but failed to archive on TCA 1.4 onwards, when macros were introduced, and this change allows it to compile and archive successfully. * Update Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift --------- Co-authored-by: Stephen Celis <[email protected]>
1 parent 88d995d commit c6b0a6c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ where State == ViewAction.State {
7070

7171
@inlinable
7272
public func reduce(into state: inout State, action: Action) -> Effect<Action> {
73-
guard let bindingAction = self.toViewAction(action).flatMap(\.binding)
73+
// NB: Using a closure and not a `\.binding` key path literal to avoid a bug with archives:
74+
// https://github.com/pointfreeco/swift-composable-architecture/pull/2641
75+
guard let bindingAction = self.toViewAction(action).flatMap({ $0.binding })
7476
else { return .none }
7577

7678
bindingAction.set(&state)

0 commit comments

Comments
 (0)