Strange Enum circular reference error in Xcode 13.3

I'm on Xcode 13.3, swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)

With this code, I get a circular reference error when building:

enum EnumA {
    case case1(Int, [EnumB])
}

enum EnumB {
    case case2(Int, [EnumB])
}

I found 2 ways to fix it.

  1. switch the order of EnumA and EnumB in my source code:
enum EnumB {
    case case2(Int, [EnumB])
}

enum EnumA {
    case case1(Int, [EnumB])
}
  1. switch the order of the 2 params for EnumA.case1:
enum EnumA {
    case case1([EnumB], Int)
}

enum EnumB {
    case case2(Int, [EnumB])
}

This looks like a bug in the toolchain.

3 Likes

Thanks for reporting this issue - it is definitely a bug in the compiler. This code used to compile in Swift 5.5, but now does not because of Sendable checking. I have filed rdar://91780682 to track getting this regression fixed. Luckily you have identified some workarounds available to you.

2 Likes