Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complier can't introduce a list of completions for Effect<Action> when using BindingReducer() in body #2386

Closed
2 of 3 tasks
ValseLee opened this issue Aug 20, 2023 · 4 comments
Labels
bug Something isn't working due to a bug in the library.

Comments

@ValseLee
Copy link
Contributor

ValseLee commented Aug 20, 2023

Description

  • I tried to find any other existing issues or discussion with keyword 'completion' but there is no single one. So I make this issue with a bug Label.
  • If I use BindingReducer() in body, compiler stops introducing a list of method completions in Effect<Action>.
  • I attached some code blocks and screen captures below.

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

  • Compiler can introduce list of method completions of Effect<Action>.
  • Compiler can introduce list of method completions of Reduce<State, Action>.

Actual behavior

  • Compiler can't introduce list of method completions of Effect<Action>.
  • Compiler can introduce list of method completions of Reduce<State, Action>.

Steps to reproduce

  1. When using BindingReducer()
struct ForIssue: Reducer {
  struct State: Equatable { var id: UUID }
  enum Action: Equatable, BindableAction {
    case binding(BindingAction<State>)
    case onButtonTapped
  }
  
  var body: some ReducerOf<Self> {
    /// if BindingReducer() exists in `body`,
    /// compiler can't introduce list of completions
    BindingReducer()

    Reduce { state, action in
      switch action {
      case .binding:
        return .none
        
      case .onButtonTapped:
        return .none
      }
    }
  }
}

image

  1. When stop using BindingReducer()
struct ForIssue: Reducer {
  struct State: Equatable { var id: UUID }
  enum Action: Equatable, BindableAction {
    case binding(BindingAction<State>)
    case onButtonTapped
  }
  
  var body: some ReducerOf<Self> {
    /// if BindingReducer() exists in `body`,
    /// compiler can't introduce list of completions
    /// BindingReducer()

    Reduce { state, action in
      switch action {
      case .binding:
        return .none
        
      case .onButtonTapped:
        return .none
      }
    }
  }
}

image

  1. Reduce<State, Action> method completions are working as normal, if body has BidningReducer() or not.
    image

The Composable Architecture version information

beta 1.0.0

Destination operating system

iOS 16.2

Xcode version information

14.2 (14C18)

Swift Compiler version information

swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0
@ValseLee ValseLee added the bug Something isn't working due to a bug in the library. label Aug 20, 2023
@nivanchikov
Copy link

nivanchikov commented Aug 20, 2023

@ValseLee can you try this tip by specifying the generics of your Reduce reducer: Reduce<State, Action> { state, action in … } as per this comment by @tgrapperon:
#1666 (comment)

public var body: some ReducerOf<Self> {
  BindingReducer()
  
  Reduce<State, Action> { state, action in
    switch action {
      ... 
    }
  }
}

It generally helped me in similar situations.

@ValseLee
Copy link
Contributor Author

@nivanchikov So.... I didn't try your solution before, but it is perfectly working!
Thank you for your kind explanation with #1666 !

@stephencelis
Copy link
Member

@ValseLee This was fixed in a later Xcode, as well. If you can upgrade from 14.2, which was released last year, to 14.3.1, this should be fixed without the need of those generics!

@JeongAYoo
Copy link

JeongAYoo commented Apr 3, 2024

@stephencelis I'm working on Xcode 15.0.1 with TCA 1.9.2 (destination target is iOS 16)
but I have the exact same problem described above...
Is there something to check in project's build settings?

(Reduce<State, Action> { state, action in … } this works for me though)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working due to a bug in the library.
Projects
None yet
Development

No branches or pull requests

4 participants