Closed stefancodinglands closed 8 months ago
I wonder if the type generation instead of some Reducer should be an option because it was written to avoid a bug and from a progressive disclosure point of view it push users who look at the generated code to not user some ReducerOf ?
I wonder if the type generation instead of some Reducer should be an option because it was written to avoid a bug and from a progressive disclosure point of view it push users who look at the generated code to not user some ReducerOf ?
Maybe that's an option too. However the fix is pretty simple, as I copied all the code generated by the macro, changed Scope to ComposableArchitecture.Scope and then everything worked.
This proposed change is in line with the way Scope is used inside the body generated by the macro (in both 1.8.0 and 1.8.1). See the image bellow, Scope is never used without the namespace.
(This image is from 1.8.0 version, but the only thing that's different is the type of the body property, not the body itself)
I agree this should be fixed anyway
Hi @stefancodinglands, thanks for the report. The fix is definitely to simply namespace the types in the macro expanded code. I accidentally left that off. I can get to it in a few hours, or you can PR a fix in the meantime.
This has been fixed in 1.8.2.
Description
2827 This PR introduced a regression because Scope is not namespaced and it can collide with something else.
It impacts code like the following:
The problem is the type of the body property:
However, changing the Scope to ComposableArchitecture.Scope fixes it. For example
Scope<Self.State, Self.Action, AuthViewReducer>
doesn't compile, butComposableArchitecture.Scope<Self.State, Self.Action, AuthViewReducer>
.Checklist
main
branch of this package.Expected behavior
I expect the generated macro to be valid code as it was in 1.8.0
Actual behavior
The code doesn't compile anymore.
Steps to reproduce
Unfortunately I don't know how to reproduce it as I can't seem to find any other dependency in my project that provides a Scope definition.
The Composable Architecture version information
1.8.1
Destination operating system
iOS 17.2
Xcode version information
Version 15.2 (15C500b)
Swift Compiler version information