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
Fix macro compiler bug in release mode. #2827
Conversation
// case feature(Feature) | ||
// } | ||
// } | ||
enum TestEnumReducer_Basics { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests were failing on CI before the enum-reducers branch was merged, and in haste I just commented them out because I thought it was due to something else. Well, turns out it was catching the problem this PR fixes. So now we can bring them back.
staticVarBody.append(">, ") | ||
} | ||
staticVarBody.removeLast(2) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is messy code, but it essentially generates a type like this:
ReducerBuilder<Self.State, Self.Action>._Sequence<
ReducerBuilder<Self.State, Self.Action>._Sequence<
ReducerBuilder<Self.State, Self.Action>._Sequence<
Scope<Self.State, Self.Action, Feature1>,
Scope<Self.State, Self.Action, Feature2>
>,
Scope<Self.State, Self.Action, Feature3>
>,
Scope<Self.State, Self.Action, Feature4>
>
…from a list of Scope
types.
…ure to from: "1.8.1" (#926) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [pointfreeco/swift-composable-architecture](https://togithub.com/pointfreeco/swift-composable-architecture) | patch | `from: "1.8.0"` -> `from: "1.8.1"` | --- ### Release Notes <details> <summary>pointfreeco/swift-composable-architecture (pointfreeco/swift-composable-architecture)</summary> ### [`v1.8.1`](https://togithub.com/pointfreeco/swift-composable-architecture/releases/tag/1.8.1) [Compare Source](https://togithub.com/pointfreeco/swift-composable-architecture/compare/1.8.0...1.8.1) #### What's Changed - Infrastructure: Document `@Reducer(state: .equatable)` in the migration guide [pointfreeco/swift-composable-architecture#2796 - Infrastructure: Adopt complete concurrency and fix a few warnings [pointfreeco/swift-composable-architecture#2787 - Fixed: \[macro] Make \_$id and \_$willModify() public by [@​freak4pc](https://togithub.com/freak4pc) in [pointfreeco/swift-composable-architecture#2789 - Fixed: Typo by [@​hmhv](https://togithub.com/hmhv) in [pointfreeco/swift-composable-architecture#2797 - Infrastructure: A small change on migration guide 1.8 by [@​takehilo](https://togithub.com/takehilo) in [pointfreeco/swift-composable-architecture#2799 - Infrastructure: Update links to documentation by [@​d-date](https://togithub.com/d-date) in [pointfreeco/swift-composable-architecture#2801 - Infrastructure: Replace usage of 'viewStore' with 'store' in UIKit code by [@​juliensagot](https://togithub.com/juliensagot) in [pointfreeco/swift-composable-architecture#2820 - Fixed Fix macro compiler bug in release mode [pointfreeco/swift-composable-architecture#2827 **Full Changelog**: pointfreeco/swift-composable-architecture@1.8.0...1.8.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDAuMCIsInVwZGF0ZWRJblZlciI6IjM2LjEwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
Fixes #2824.
There is a Swift compiler/macro bug that causes the compiler to choke on constrained opaque types (e.g.
some Reducer<State, Action>
) when theState
andAction
are also generated by the macro. It doesn't happen in all situations, but something about enum reducers exacerbates the problem (perhaps it's cause of thestatic var body
?).The fix is to just not use opaque types in the macro generated code and instead expand the whole type for the
static var body
. It's a bit messy, but it works.