pointfreeco/swift-composable-architecture

New Destination/Path reducer crashes SwiftCompile in release configuration

JanGorman opened this issue · 3 comments

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.

  • Debug: -Onone
  • Release: -O

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

We would like to use the new @Reducer like this to model a navigation path

@Reducer
enum Path {
  case childFeature(ChildFeature)
}

Actual behavior

When building for release, we get a compiler crash

[cleanup]   %5 = load [take] %3 : $*CombineReducers<RootFeature.Path.State, RootFeature.Path.Action, Scope<RootFeature.Path.State, RootFeature.Path.Action, ChildFeature>>
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/jangorman/my/tmp/ReducerExample/ReducerExample/ContentView.swift /Users/jangorman/my/tmp/ReducerExample/ReducerExample/RootFeature.swift /Users/jangorman/my/tmp/ReducerExample/ReducerExample/ReducerExampleApp.swift /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/DerivedSources/GeneratedAssetSymbols.swift -supplementary-output-file-map /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/supplementaryOutputs-484 -emit-localized-strings -emit-localized-strings-path /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64 -target arm64-apple-ios17.2 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk -I /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/PackageFrameworks -F /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos -no-color-diagnostics -g -module-cache-path /Users/jangorman/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -O -serialize-debugging-options -load-plugin-executable /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/UninstalledProducts/macosx/CasePathsMacros#CasePathsMacros -load-plugin-executable /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/UninstalledProducts/macosx/ComposableArchitectureMacros#ComposableArchitectureMacros -load-plugin-executable /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/UninstalledProducts/macosx/DependenciesMacrosPlugin#DependenciesMacrosPlugin -load-plugin-executable /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/UninstalledProducts/macosx/PerceptionMacros#PerceptionMacros -const-gather-protocols-file /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/ReducerExample_const_extract_protocols.json -enable-bare-slash-regex -empty-abi-descriptor -validate-clang-modules-once -clang-build-session-file /Users/jangorman/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/jangorman/my/tmp/ReducerExample -resource-dir /Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -Xcc -ivfsstatcache -Xcc /Users/jangorman/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphoneos17.2-21C52-d4853233c81beb1da90379997a312ef0.sdkstatcache -Xcc -I/Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/ReducerExample-generated-files.hmap -Xcc -I/Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/ReducerExample-own-target-headers.hmap -Xcc -I/Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/ReducerExample-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/ReducerExample-project-headers.hmap -Xcc -I/Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/BuildProductsPath/Release-iphoneos/include -Xcc -I/Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/DerivedSources-normal/arm64 -Xcc -I/Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/DerivedSources/arm64 -Xcc -I/Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/DerivedSources -module-name ReducerExample -frontend-parseable-output -disable-clang-spi -target-sdk-version 17.2 -target-sdk-name iphoneos17.2 -external-plugin-path /Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/lib/swift/host/plugins#/Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -num-threads 10 -o /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/ContentView.o -o /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/RootFeature.o -o /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/ReducerExampleApp.o -o /Users/jangorman/Library/Developer/Xcode/DerivedData/ReducerExample-fgbvgirnpqchjygksuwbgrhombyr/Build/Intermediates.noindex/ArchiveIntermediates/ReducerExample/IntermediateBuildFilesPath/ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/GeneratedAssetSymbols.o -index-unit-output-path /ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/ContentView.o -index-unit-output-path /ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/RootFeature.o -index-unit-output-path /ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/ReducerExampleApp.o -index-unit-output-path /ReducerExample.build/Release-iphoneos/ReducerExample.build/Objects-normal/arm64/GeneratedAssetSymbols.o
1.	Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
2.	Compiling with the current language version
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module ReducerExample)
4.	While generating SIL witness table protocol conformance to 'Reducer' (in module 'ComposableArchitecture') for type 'RootFeature.Path' (declared at [/Users/jangorman/my/tmp/ReducerExample/ReducerExample/RootFeature.swift:12:5 - line:14:5] RangeText="enum Path {
        case childFeature(ChildFeature)
    ")
5.	While generating protocol witness thunk SIL function "@$s14ReducerExample11RootFeatureV4PathO22ComposableArchitecture0A0AafGP4body4BodyQzvgTW".
 for getter for body (in module 'ComposableArchitecture')
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000102e11abc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105a77cb0 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001057e1054 SignalHandler(int) + 352
3  libsystem_platform.dylib 0x000000018b635a24 _sigtramp + 56
4  swift-frontend           0x000000010373da28 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) (.llvm.10993375518856827296) + 6988
5  swift-frontend           0x00000001037b56f4 (anonymous namespace)::ResultPlanner::execute(llvm::SmallVectorImpl<swift::SILValue>&, llvm::SmallVectorImpl<swift::SILValue>&)::$_33::operator()((anonymous namespace)::ResultPlanner::Operation&, bool, bool) const + 516
6  swift-frontend           0x0000000103748f78 (anonymous namespace)::ResultPlanner::execute(swift::SILValue, swift::CanTypeWrapper<swift::SILFunctionType>) + 1036
7  swift-frontend           0x000000010374d97c swift::Lowering::SILGenFunction::emitProtocolWitness(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILDeclRef, swift::SubstitutionMap, swift::SILDeclRef, swift::SubstitutionMap, swift::Lowering::IsFreeFunctionWitness_t, bool, llvm::Optional<swift::ActorIsolation>) + 5344
8  swift-frontend           0x000000010385f21c swift::Lowering::SILGenModule::emitProtocolWitness(swift::ProtocolConformanceRef, swift::SILLinkage, swift::IsSerialized_t, swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) + 3840
9  swift-frontend           0x0000000103868444 (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Witness) + 360
10 swift-frontend           0x000000010386792c (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethod(swift::SILDeclRef) + 1424
11 swift-frontend           0x0000000103865a54 void llvm::function_ref<void (swift::AccessorDecl*)>::callback_fn<swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitAbstractStorageDecl(swift::AbstractStorageDecl*)::'lambda'(swift::AccessorDecl*)>(long, swift::AccessorDecl*) + 96
12 swift-frontend           0x0000000103347eb8 swift::AbstractStorageDecl::visitExpectedOpaqueAccessors(llvm::function_ref<void (swift::AccessorKind)>) const + 288
13 swift-frontend           0x0000000103864c88 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 1888
14 swift-frontend           0x000000010385b884 swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) + 588
15 swift-frontend           0x0000000103862a58 SILGenExtension::emitExtension(swift::ExtensionDecl*) + 600
16 swift-frontend           0x000000010312e790 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 444
17 swift-frontend           0x0000000103153d90 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 4844
18 swift-frontend           0x0000000103822f98 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 200
19 swift-frontend           0x00000001031799ac llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 584
20 swift-frontend           0x000000010315517c swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 152
21 swift-frontend           0x0000000105354ee4 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2992
22 swift-frontend           0x0000000105358854 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
23 swift-frontend           0x00000001053bfd44 swift::mainEntry(int, char const**) + 4408
24 dyld                     0x000000018b2850e0 start + 2360
Command SwiftCompile failed with a nonzero exit code

Steps to reproduce

This is small snippet is enough to reproduce the crash in a project:

@Reducer
struct RootFeature {

    @Reducer
    enum Path {
        case childFeature(ChildFeature)
    }
}

Hand rolling the code as you would pre 1.8.0 works fine

@Reducer
struct RootFeature {

    @Reducer
    struct Path {
        @ObservableState
        enum State {
            case childFeature(ChildFeature.State)
        }

        enum Action {
            case childFeature(ChildFeature.Action)
        }

        var body: some ReducerOf<Self> {
            Scope(state: \.childFeature, action: \.childFeature) {
                ChildFeature()
            }
        }
    }
}

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

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0

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.