Closed JanGorman closed 8 months ago
Hi @JanGorman, unfortunately this is a compiler bug with macros. It seems the compiler has trouble figuring out this opaque type:
static var body: some ComposableArchitecture.Reducer<Self.State, Self.Action> {
…when the macro generates all of the parts. As you noted, expanding manual compiles just fine, and in fact another workaround is to just implement one of the requirements:
@Reducer
enum Destination {
case feature(Feature)
@CasePathable
enum Action {
case feature(Feature.Action)
}
}
@Reducer struct Feature {}
That right there compiles fine. For some reason explicitly providing Destination.Action
instead of letting the macro generate it is enough to help the compiler.
So, I believe the proper fix is for the macro to generate the actual type of static var body
and not use opaque types, but that is quite complex and so will take us some type to get a fix out.
And in the meantime if you simply provide the Action
enum yourself inside Destination
, it should work. Can you give that a shot and let us know how it goes?
A fix for this was released in 1.8.1. Can you update and verify it is fixed?
Thanks @mbrandonw – I saw the initial response last night and wasn't expecting to see a workaround for the issue in the morning 🤩 . I tested this and can confirm that it solves the issue. Thanks for all the great work you folks are doing.
Description
We upgraded to 1.8.0 and were excited to try the new
@Reducer
capabilities to remove some boilerplate from a navigation path reducer. This works fine in debug builds but unfortunately crashes the compiler in release configuration. The Swift compiler settings are left at their default settings, i.e.-Onone
-O
Checklist
main
branch of this package.Expected behavior
We would like to use the new
@Reducer
like this to model a navigation pathActual behavior
When building for release, we get a compiler crash
Steps to reproduce
This is small snippet is enough to reproduce the crash in a project:
Hand rolling the code as you would pre 1.8.0 works fine
The Composable Architecture version information
1.8.0
Destination operating system
iOS 16, iOS 17
Xcode version information
Version 15.2 (15C500b)
Swift Compiler version information