Skip to content

Adds disfavoredOverload annotation to ~= implementation in Binding.swift#3911

Merged
stephencelis merged 1 commit intopointfreeco:mainfrom
rprince500:rprince500/add-disfavoredOverload-in-BindingAction
Apr 1, 2026
Merged

Adds disfavoredOverload annotation to ~= implementation in Binding.swift#3911
stephencelis merged 1 commit intopointfreeco:mainfrom
rprince500:rprince500/add-disfavoredOverload-in-BindingAction

Conversation

@rprince500
Copy link
Copy Markdown
Contributor

When running versions of TCA >= 1.24.0 on Xcode 26.4, our team's project fails to compile with several instances of the following compiler error: Ambiguous use of operator '~='

It looks like the compiler is having trouble disambiguating between this function and the more constrained implementation declared in Binding+Observation.swift, where the only difference is the additional where Root: ObservableState constraint.

I've confirmed that adding the @_disfavoredOverload annotation to the less constrained operator gets us building again.

Fixes a compiler error by helping it disambiguate between this implementation of ~= and the more constrained one declared in Binding+Observation.swift
@stephencelis
Copy link
Copy Markdown
Member

@rprince500 Thanks! Can you include a test or code snippet that demonstrates the issue so that we can confirm before merging?

@rprince500
Copy link
Copy Markdown
Contributor Author

@stephencelis

CleanShot 2026-03-31 at 22 34 32@2x

Here's a screenshot of one of the errors in our project. When I create a brand new project as an MRE, the compiler doesn't seem to choke up. I guess it's able to parse things just fine up until a certain level of complexity ¯\_(ツ)_/¯

For reference, here's the super simple code snippet that utilizes the same functionality but compiles fine in a brand new project.

import ComposableArchitecture

@Reducer
struct ExampleReducer {
    @ObservableState
    struct State: Equatable {
        var didReceiveHelloWorld = false
        var searchText = ""
    }

    enum Action: BindableAction, Equatable {
        case binding(BindingAction<State>)
        case helloWorld
    }

    var body: some ReducerOf<Self> {
        BindingReducer()
        Reduce { state, action in
            switch action {
            case .binding(\.searchText):
                return searchTextUpdated(with: &state)
            case .binding:
                return .none
            case .helloWorld:
                state.didReceiveHelloWorld = true
                return .none
            }
        }
    }

    private func searchTextUpdated(with state: inout State) -> EffectOf<Self> {
        if state.searchText == "Hello World" {
            .send(.helloWorld)
        } else {
            .none
        }
    }
}

Copy link
Copy Markdown
Member

@stephencelis stephencelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@stephencelis stephencelis merged commit b630c37 into pointfreeco:main Apr 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants