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

@DependencyClient and inout parameters #146

Closed
2 of 3 tasks
Alex293 opened this issue Nov 27, 2023 · 2 comments
Closed
2 of 3 tasks

@DependencyClient and inout parameters #146

Alex293 opened this issue Nov 27, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Alex293
Copy link
Contributor

Alex293 commented Nov 27, 2023

Description

The code generated by @DependencyClient is incorrect for inout parameters and generate invalid swift code. it should explicitly refuse to generate code or if possible generate valid code.

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

@DependencyClient
public struct AuthenticationClient {
    var authenticateRequest: (_ urlRequest: inout URLRequest) async throws  -> Void
}

Should generate valid swift code

Actual behavior

The code generated :

func authenticateRequest(urlRequest p0: inout URLRequest) async throws  -> Void {
    try await self.authenticateRequest(p0)
}

private var _authenticateRequest: (_ urlRequest: inout URLRequest) async throws  -> Void = { _ in
    XCTestDynamicOverlay.XCTFail("Unimplemented: 'authenticateRequest'")
    throw DependenciesMacros.Unimplemented("authenticateRequest")
}

is not valid code: Passing value of type 'URLRequest' to an inout parameter requires explicit '&'

Steps to reproduce

No response

Dependencies version information

1.1.1

Destination operating system

No response

Xcode version information

15.0.1

Swift Compiler version information

No response

@Alex293 Alex293 added the bug Something isn't working label Nov 27, 2023
@mbrandonw
Copy link
Member

Hey @Alex293, good catch! Do you have any interest in diving into this and trying to fix it? No worries if not, we will take a look soon.

@Alex293
Copy link
Contributor Author

Alex293 commented Nov 27, 2023

I'd love to. I'll have a look within a couple days and ping you if I'm struggling, Idon't have much experience with SwiftSyntax but I was looking to dive in.

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

No branches or pull requests

3 participants