Skip to content
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

Merged
merged 2 commits into from Feb 19, 2024
Merged

Conversation

mbrandonw
Copy link
Member

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 the State and Action 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 the static 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.

@mbrandonw mbrandonw added the apple bug Something isn't working due to a bug on Apple's platforms. label Feb 18, 2024
// case feature(Feature)
// }
// }
enum TestEnumReducer_Basics {
Copy link
Member Author

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)
}
Copy link
Member Author

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.

@mbrandonw mbrandonw merged commit da1cd10 into main Feb 19, 2024
7 checks passed
@mbrandonw mbrandonw deleted the macro-release-bug-fix branch February 19, 2024 01:05
cgrindel-self-hosted-renovate bot added a commit to cgrindel/rules_swift_package_manager that referenced this pull request Feb 19, 2024
…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
[@&#8203;freak4pc](https://togithub.com/freak4pc) in
[pointfreeco/swift-composable-architecture#2789
- Fixed: Typo by [@&#8203;hmhv](https://togithub.com/hmhv) in
[pointfreeco/swift-composable-architecture#2797
- Infrastructure: A small change on migration guide 1.8 by
[@&#8203;takehilo](https://togithub.com/takehilo) in
[pointfreeco/swift-composable-architecture#2799
- Infrastructure: Update links to documentation by
[@&#8203;d-date](https://togithub.com/d-date) in
[pointfreeco/swift-composable-architecture#2801
- Infrastructure: Replace usage of 'viewStore' with 'store' in UIKit
code by [@&#8203;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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apple bug Something isn't working due to a bug on Apple's platforms.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Destination/Path reducer crashes SwiftCompile in release configuration
1 participant