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

Result builder dynamic key path autocomplete breaks for second component #69477

Open
stephencelis opened this issue Oct 28, 2023 · 2 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@stephencelis
Copy link
Contributor

stephencelis commented Oct 28, 2023

Description

I have a project with a decently complex builder that works with objects that can be configured with key paths but am finding that only the first builder expression can autocomplete correctly. In general autocomplete is struggling with these expressions.

Steps to reproduce

  1. Clone https://github.com/pointfreeco/swift-composable-architecture

  2. Check out the case-key-paths branch (HEAD at 63ed79606882de385e22afcdf847e46277142b07 at the time of submitting this issue)

  3. Open ComposableArchitecture.xcworkspace

  4. Select "CaseStudies (SwiftUI)" build scheme

  5. Build

  6. Navigate to https://github.com/pointfreeco/swift-composable-architecture/blob/63ed79606882de385e22afcdf847e46277142b07/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Composition-TwoCounters.swift#L25

  7. Autocomplete action: \. from line 25, note:
    image

  8. Autocomplete action: \. from line 28, note:
    image

Bonus bug:

  • Autocomplete state: \. from either and neither completes correctly:
    image

    Scope has two initializer overloads of state: for two different kinds of key paths, but State only qualifies for one in this case, yet it's choosing the wrong overload to complete from.

Expected behavior

I expect autocomplete to work.

Environment

  • Swift compiler version info
    swift-driver version: 1.87.2 Apple Swift version 5.9 (swiftlang-5.9.2.1.6     clang-1500.1.0.1.1)
    Target: arm64-apple-macosx14.0
    
  • Xcode version info
    Xcode 15.1
    Build version 15C5028h
    
@stephencelis stephencelis added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Oct 28, 2023
@stephencelis
Copy link
Contributor Author

/cc @xedin

Please let me know if I'm missing something in the project's result builder that could address these usability issues.

@stephencelis
Copy link
Contributor Author

This seems to be an order of operation of builder type checking vs. macro expansion. If I explicitly add : Reducer (in addition to the @Reducer macro) this restores the above action: autocomplete and others, though there are complex situations, like Reduce { state, action in … } blocks in which state. and switch action { case . do not autocomplete till generics are qualified, e.g., Reduce<State, Action> { state, action in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant