Dependencies macro tries to initialize static vars #200
BastianKusserow
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi @BastianKusserow, this can certainly be fixed, but static vars are not safe to use in Swift 6 (on non-global actors at least), and so this really isn't something you should be doing anyway. If you turn on concurrency checks you will get the following warning:
If you have any interest in fixing we would happily take a PR, but I'm not sure when we will have the time to look into it. For now I am going to convert this to a discussion since it is not a top priority for us, so please continue any discussion over there. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Hey!
Seems like the DependencyClient macro tries to initialize static vars within the generated init.
So the following code
generates
This does not compile for obvious reasons. Is this just an oversight in the macros implementation or should static vars just not be supported?
Checklist
main
branch of this package.Expected behavior
I'd expect that the static var is just ignored in the initializer. However, as I was seeing the issue, I was also searching for something like
@DependencyEndpointIgnored
to somehow mitigate the issue. Maybe thats also something worth exploring?Actual behavior
The initializer tries to initialize the static var, which is not possible.
Steps to reproduce
No response
Dependencies version information
No response
Destination operating system
No response
Xcode version information
No response
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions