Closed larryonoff closed 4 months ago
@larryonoff This feature was added recently: https://github.com/pointfreeco/swift-composable-architecture/pull/2814
The macro has no knowledge of what the type of reducer being fed to a case is, so outside the default, you must specify the exact reducer kind and how to construct it using a default argument:
@Reducer(state: .equatable)
enum Feature2 {
case feature1(Feature1.Body = Feature1.body)
}
Does this work for you?
@stephencelis thank you! it works like a charm!
Is it in the docs already?
@larryonoff I don't believe it's documented yet, but we'll PR some later today!
Description
The case is pretty simple. The error occurs if you have nested macro-generated enum reducer (e.g. Feature1) in another macro-generated enum reducer (.e.g. Feature2).
Looks that issue occurs since Reducer macro doesn't take into account that macro-generated enum Reducers don't have inits.
Checklist
main
branch of this package.Expected behavior
No error occurs.
Actual behavior
Compiler reports an error:
'Type' cannot be constructed because it has no accessible initializers
Steps to reproduce
See the code below.
The Composable Architecture version information
1.10.2
Destination operating system
No response
Xcode version information
Version 15.3 (15E204a)
Swift Compiler version information