swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.39k stars 10.34k forks source link

Macro assertion failure around opaque types #74107

Open stephencelis opened 4 months ago

stephencelis commented 4 months ago

Description

I have a project that has CI against Apple platforms, as well as Linux and Windows, and noticed that a change to a macro suddenly caused the Windows build to fail. @compnerd said it seems like a generic issue and not Windows-specific. I unfortunately do not have a custom debug build to work with to reduce things, but I can link to the PR that introduces the problem:

https://github.com/pointfreeco/swift-case-paths/pull/159

Reproduction

  1. Clone the above repo and check out the case-path-iteration branch.
  2. Try running swift test on it using a debug build

Stack dump

error: failed parsing the Swift compiler output: unexpected JSON message: {
  "exception" : 3,
  "kind" : "abnormal-exit",
  "name" : "compile",
  "output" : "<unknown>:0: warning: cannot form key path that captures non-sendable type 'KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>'\r\nSwift.KeyPath:1:14: note: generic class 'KeyPath' does not conform to the 'Sendable' protocol\r\npublic class KeyPath<Root, Value> : PartialKeyPath<Root> {\r\n             ^\r\n<unknown>:0: warning: cannot form key path that captures non-sendable type 'KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>'\r\nSwift.KeyPath:1:14: note: generic class 'KeyPath' does not conform to the 'Sendable' protocol\r\npublic class KeyPath<Root, Value> : PartialKeyPath<Root> {\r\n             ^\r\nindirect result type mismatch!\r\n  argument: %0 = argument of bb0 : $*@_opaqueReturnTypeOf(\"$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF\", 0) __ \/\/ user: %23\r\n  expected: $*IndexingIterator<Array<PartialKeyPath<Case<Foo>>>>\r\nSIL verification failed: entry point argument types do not match function type: matched\r\nIn function:\r\n\/\/ Foo.AllCasePaths.makeIterator()\r\nsil [ossa] @$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF : $@convention(method) (Foo.AllCasePaths) -> @out @_opaqueReturnTypeOf(\"$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF\", 0) __ {\r\n\/\/ %0 \"$return_value\"                             \/\/ user: %23\r\n\/\/ %1 \"self\"                                      \/\/ user: %2\r\nbb0(%0 : $*@_opaqueReturnTypeOf(\"$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF\", 0) __, %1 : $Foo.AllCasePaths):\r\n  debug_value %1 : $Foo.AllCasePaths, let, name \"self\", argno 1, implicit \/\/ id: %2\r\n  %3 = alloc_box ${ var Array<PartialKeyPath<Case<Foo>>> }, var, name \"allCasePaths\" \/\/ users: %33, %4\r\n  %4 = begin_borrow [var_decl] %3 : ${ var Array<PartialKeyPath<Case<Foo>>> } \/\/ users: %32, %5\r\n  %5 = project_box %4 : ${ var Array<PartialKeyPath<Case<Foo>>> }, 0 \/\/ users: %24, %18, %12\r\n  %6 = integer_literal $Builtin.Word, 0           \/\/ user: %8\r\n  \/\/ function_ref _allocateUninitializedArray<A>(_:)\r\n  %7 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) \/\/ user: %8\r\n  %8 = apply %7<PartialKeyPath<Case<Foo>>>(%6) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) \/\/ user: %9\r\n  (%9, %10) = destructure_tuple %8 : $(Array<PartialKeyPath<Case<Foo>>>, Builtin.RawPointer) \/\/ users: %12, %11\r\n  %11 = pointer_to_address %10 : $Builtin.RawPointer to [strict] $*PartialKeyPath<Case<Foo>>\r\n  store %9 to [init] %5 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ id: %12\r\n  %13 = keypath $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>, (root $Foo.AllCasePaths; gettable_property $AnyCasePath<Foo, Foo2>,  id @$s26swift_case_paths_benchmark3FooO12AllCasePathsV3foo0gH003AnyG4PathVyAcA4Foo2OGvg : $@convention(method) (Foo.AllCasePaths) -> @owned AnyCasePath<Foo, Foo2>, getter @$s26swift_case_paths_benchmark3FooO12AllCasePathsV3foo0gH003AnyG4PathVyAcA4Foo2OGvpAETK : $@convention(thin) (@in_guaranteed Foo.AllCasePaths) -> @out AnyCasePath<Foo, Foo2>) \/\/ user: %14\r\n  %14 = keypath $KeyPath<Case<Foo>, Case<Foo2>>, (root $Case<Foo>; gettable_property $Case<Foo2>,  id @$s9CasePaths0A0V13dynamicMemberACyqd__Gs7KeyPathCy03AllaB0QzAA03AnyaF0Vyxqd__GG_tcAA0A8PathableRzluig : $@convention(method) <τ_0_0 where τ_0_0 : CasePathable><τ_1_0> (@guaranteed KeyPath<τ_0_0.AllCasePaths, AnyCasePath<τ_0_0, τ_1_0>>, @guaranteed Case<τ_0_0>) -> @owned Case<τ_1_0>, getter @$s9CasePaths0A0V13dynamicMemberACyqd__Gs7KeyPathCy03AllaB0QzAA03AnyaF0Vyxqd__GG_tcAA0A8PathableRzluipACy26swift_case_paths_benchmark3FooOGAqO4Foo2OTK : $@convention(thin) (@in_guaranteed Case<Foo>, UnsafeRawPointer) -> @out Case<Foo2>, indices [%$0 : $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>> : $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>], indices_equals @$ss7KeyPathCy26swift_case_paths_benchmark3FooO12AllCasePathsV0iJ003AnyiB0VyAeC4Foo2OGGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$ss7KeyPathCy26swift_case_paths_benchmark3FooO12AllCasePathsV0iJ003AnyiB0VyAeC4Foo2OGGTh : $@convention(thin) (UnsafeRawPointer) -> Int, external #Case.subscript<Foo, Foo2>) (%13) \/\/ user: %15\r\n  %15 = upcast %14 : $KeyPath<Case<Foo>, Case<Foo2>> to $PartialKeyPath<Case<Foo>> \/\/ user: %17\r\n  %16 = alloc_stack $PartialKeyPath<Case<Foo>>    \/\/ users: %22, %20, %17\r\n  store %15 to [init] %16 : $*PartialKeyPath<Case<Foo>> \/\/ id: %17\r\n  %18 = begin_access [modify] [unknown] %5 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ users: %21, %20\r\n  \/\/ function_ref Array.append(_:)\r\n  %19 = function_ref @$sSa6appendyyxnF : $@convention(method) <τ_0_0> (@in τ_0_0, @inout Array<τ_0_0>) -> () \/\/ user: %20\r\n  %20 = apply %19<PartialKeyPath<Case<Foo>>>(%16, %18) : $@convention(method) <τ_0_0> (@in τ_0_0, @inout Array<τ_0_0>) -> ()\r\n  end_access %18 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ id: %21\r\n  dealloc_stack %16 : $*PartialKeyPath<Case<Foo>> \/\/ id: %22\r\n  %23 = unchecked_addr_cast %0 : $*@_opaqueReturnTypeOf(\"$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF\", 0) __ to $*IndexingIterator<Array<PartialKeyPath<Case<Foo>>>> \/\/ user: %30\r\n  %24 = begin_access [read] [unknown] %5 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ users: %26, %25\r\n  %25 = load [copy] %24 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ user: %28\r\n  end_access %24 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ id: %26\r\n  %27 = alloc_stack $Array<PartialKeyPath<Case<Foo>>> \/\/ users: %31, %30, %28\r\n  store %25 to [init] %27 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ id: %28\r\n  \/\/ function_ref Collection<>.makeIterator()\r\n  %29 = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in τ_0_0) -> @out IndexingIterator<τ_0_0> \/\/ user: %30\r\n  %30 = apply %29<[PartialKeyPath<Case<Foo>>]>(%23, %27) : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in τ_0_0) -> @out IndexingIterator<τ_0_0>\r\n  dealloc_stack %27 : $*Array<PartialKeyPath<Case<Foo>>> \/\/ id: %31\r\n  end_borrow %4 : ${ var Array<PartialKeyPath<Case<Foo>>> } \/\/ id: %32\r\n  destroy_value %3 : ${ var Array<PartialKeyPath<Case<Foo>>> } \/\/ id: %33\r\n  %34 = tuple ()                                  \/\/ user: %35\r\n  return %34 : $()                                \/\/ id: %35\r\n} \/\/ end sil function '$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF'\r\n\r\nPlease submit a bug report (https:\/\/swift.org\/contributing\/#reporting-bugs) and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: C:\/Users\/runneradmin\/AppData\/Local\/Programs\/Swift\/Toolchains\/5.10.0+Asserts\/usr\/bin\/swift-frontend.exe -frontend -c D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\Sources\\\\swift-case-paths-benchmark\\\\Common.swift -primary-file D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\Sources\\\\swift-case-paths-benchmark\\\\Foo.swift D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\Sources\\\\swift-case-paths-benchmark\\\\main.swift -emit-dependencies-path D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\.build\\\\x86_64-unknown-windows-msvc\\\\debug\\\\swift_case_paths_benchmark.build\\\\Foo.d -emit-reference-dependencies-path D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\.build\\\\x86_64-unknown-windows-msvc\\\\debug\\\\swift_case_paths_benchmark.build\\\\Foo.swiftdeps -target x86_64-unknown-windows-msvc -disable-objc-interop -sdk C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Programs\\\\Swift\\\\Platforms\\\\5.10.0\\\\Windows.platform\\\\Developer\\\\SDKs\\\\Windows.sdk -I D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\.build\\\\x86_64-unknown-windows-msvc\\\\debug -I C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Programs\\\\Swift\\\\Platforms\\\\5.10.0\\\\Windows.platform\\\\Developer\\\\Library\\\\XCTest-development\\\\usr\\\\lib\\\\swift\\\\windows -I C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Programs\\\\Swift\\\\Platforms\\\\5.10.0\\\\Windows.platform\\\\Developer\\\\Library\\\\XCTest-development\\\\usr\\\\lib\\\\swift\\\\windows\\\\x86_64 -enable-testing -g -module-cache-path D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\.build\\\\x86_64-unknown-windows-msvc\\\\debug\\\\ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -load-plugin-executable D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\.build\\\\x86_64-unknown-windows-msvc\\\\debug\\\\CasePathsMacros.exe#CasePathsMacros -enable-experimental-feature StrictConcurrency -empty-abi-descriptor -resource-dir C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Programs\\\\Swift\\\\Toolchains\\\\5.10.0+Asserts\\\\usr\\\\lib\\\\swift -enable-anonymous-context-mangled-names -Xcc -D_MT -Xcc -D_DLL -Xcc -Xclang -Xcc --dependent-lib=msvcrt -Xcc -gdwarf -module-name swift_case_paths_benchmark -package-name swift_case_paths -plugin-path C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Programs\\\\Swift\\\\Toolchains\\\\5.10.0+Asserts\\\\usr\\\\bin -plugin-path C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Programs\\\\Swift\\\\Toolchains\\\\5.10.0+Asserts\\\\usr\\\\local\\\\bin -o D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\.build\\\\x86_64-unknown-windows-msvc\\\\debug\\\\swift_case_paths_benchmark.build\\\\Foo.swift.o -index-store-path D:\\\\a\\\\swift-case-paths\\\\swift-case-paths\\\\.build\\\\x86_64-unknown-windows-msvc\\\\debug\\\\index\\\\store -index-system-modules\r\n1.\tSwift version 5.10 (swift-5.10-RELEASE)\r\n2.\tCompiling with the current language version\r\n3.\tWhile evaluating request ASTLoweringRequest(Lowering AST to SIL for file \"D:\\a\\swift-case-paths\\swift-case-paths\\Sources\\swift-case-paths-benchmark\\Foo.swift\")\r\n4.\tWhile silgen emitFunction SIL function \"@$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF\".\r\n for 'makeIterator()' (at @__swiftmacro_26swift_case_paths_benchmark3Foo12CasePathablefMm_.swift:19:12)\r\n5.\tWhile verifying SIL function \"@$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF\".\r\n for 'makeIterator()' (at @__swiftmacro_26swift_case_paths_benchmark3Foo12CasePathablefMm_.swift:19:12)\r\nException Code: 0x80000003\r\n #0 0x00007ff77e480555 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x5960555)\r\n #1 0x00007ff9380ebb04 (C:\\Windows\\System32\\ucrtbase.dll+0x7bb04)\r\n #2 0x00007ff9380ecad1 (C:\\Windows\\System32\\ucrtbase.dll+0x7cad1)\r\n #3 0x00007ff779d3d0e1 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x121d0e1)\r\n #4 0x00007ff779d46cc9 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x1226cc9)\r\n #5 0x00007ff779d37dc9 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x1217dc9)\r\n #6 0x00007ff779451c0e (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x931c0e)\r\n #7 0x00007ff77944a456 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x92a456)\r\n #8 0x00007ff77944b7cd (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x92b7cd)\r\n #9 0x00007ff779447efc (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x927efc)\r\n#10 0x00007ff779489058 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x969058)\r\n#11 0x00007ff779488792 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x968792)\r\n#12 0x00007ff779483952 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x963952)\r\n#13 0x00007ff7794884fa (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x9684fa)\r\n#14 0x00007ff779483952 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x963952)\r\n#15 0x00007ff779489228 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x969228)\r\n#16 0x00007ff77944ba23 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x92ba23)\r\n#17 0x00007ff77944c311 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x92c311)\r\n#18 0x00007ff779452d76 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x932d76)\r\n#19 0x00007ff779443c38 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x923c38)\r\n#20 0x00007ff77945191c (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x93191c)\r\n#21 0x00007ff778e21cad (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x301cad)\r\n#22 0x00007ff778e204b8 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x3004b8)\r\n#23 0x00007ff778e20a8b (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x300a8b)\r\n#24 0x00007ff778e23112 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x303112)\r\n#25 0x00007ff778ca42b6 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x1842b6)\r\n#26 0x00007ff778ca3cc9 (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x183cc9)\r\n#27 0x00007ff77e50ae1c (C:\\Users\\runneradmin\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.0+Asserts\\usr\\bin\\swift-frontend.exe+0x59eae1c)\r\n#28 0x00007ff939d24cb0 (C:\\Windows\\System32\\KERNEL32.DLL+0x14cb0)\r\n#29 0x00007ff93a85e8ab (C:\\Windows\\SYSTEM32\\ntdll.dll+0x7e8ab)\r\n",
  "pid" : 5852,
  "process" : {
    "real_pid" : 5852
  }
}: dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "kind", intValue: nil)], debugDescription: "invalid kind", underlyingError: nil))

Expected behavior

No crash.

Environment

5.10+

Additional information

No response

compnerd commented 4 months ago

The remainder of the log is critical. It was a SIL verification failure indicating a bug in SILSen.

stephencelis commented 4 months ago

@compnerd I believe the log is all captured above, but here's the full link (it may expire in the future): https://github.com/pointfreeco/swift-case-paths/actions/runs/9357788886/job/25758324959?pr=159

hjyamauchi commented 4 months ago

I was able to reproduce this on macOS with the latest 5.10 release and the 5.9.2 release.

So this doesn't seem Windows-specific and @stephencelis you should be able to reproduce and reduce by using the above releases.

CC @compnerd

5.10

git clone https://github.com/pointfreeco/swift-case-paths -b case-path-iteration
cd swift-case-paths
~/Library/Developer/Toolchains/swift-5.10-RELEASE.xctoolchain/usr/bin/swift test
...
public class KeyPath<Root, Value> : PartialKeyPath<Root> {
             ^
indirect result type mismatch!
  argument: %0 = argument of bb0 : $*@_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __ // user: %23
  expected: $*IndexingIterator<Array<PartialKeyPath<Case<Foo>>>>
SIL verification failed: entry point argument types do not match function type: matched
In function:
// Foo.AllCasePaths.makeIterator()
sil [ossa] @$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF : $@convention(method) (Foo.AllCasePaths) -> @out @_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __ {
// %0 "$return_value"                             // user: %23
// %1 "self"                                      // user: %2
bb0(%0 : $*@_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __, %1 : $Foo.AllCasePaths):
  debug_value %1 : $Foo.AllCasePaths, let, name "self", argno 1, implicit // id: %2
  %3 = alloc_box ${ var Array<PartialKeyPath<Case<Foo>>> }, var, name "allCasePaths" // users: %33, %4
  %4 = begin_borrow [var_decl] %3 : ${ var Array<PartialKeyPath<Case<Foo>>> } // users: %32, %5
  %5 = project_box %4 : ${ var Array<PartialKeyPath<Case<Foo>>> }, 0 // users: %24, %18, %12
  %6 = integer_literal $Builtin.Word, 0           // user: %8
  // function_ref _allocateUninitializedArray<A>(_:)
  %7 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %8
  %8 = apply %7<PartialKeyPath<Case<Foo>>>(%6) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %9
  (%9, %10) = destructure_tuple %8 : $(Array<PartialKeyPath<Case<Foo>>>, Builtin.RawPointer) // users: %12, %11
  %11 = pointer_to_address %10 : $Builtin.RawPointer to [strict] $*PartialKeyPath<Case<Foo>>
  store %9 to [init] %5 : $*Array<PartialKeyPath<Case<Foo>>> // id: %12
  %13 = keypath $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>, (root $Foo.AllCasePaths; gettable_property $AnyCasePath<Foo, Foo2>,  id @$s26swift_case_paths_benchmark3FooO12AllCasePathsV3foo0gH003AnyG4PathVyAcA4Foo2OGvg : $@convention(method) (Foo.AllCasePaths) -> @owned AnyCasePath<Foo, Foo2>, getter @$s26swift_case_paths_benchmark3FooO12AllCasePathsV3foo0gH003AnyG4PathVyAcA4Foo2OGvpAETK : $@convention(thin) (@in_guaranteed Foo.AllCasePaths) -> @out AnyCasePath<Foo, Foo2>) // user: %14
  %14 = keypath $KeyPath<Case<Foo>, Case<Foo2>>, (root $Case<Foo>; gettable_property $Case<Foo2>,  id @$s9CasePaths0A0V13dynamicMemberACyqd__Gs7KeyPathCy03AllaB0QzAA03AnyaF0Vyxqd__GG_tcAA0A8PathableRzluig : $@convention(method) <τ_0_0 where τ_0_0 : CasePathable><τ_1_0> (@guaranteed KeyPath<τ_0_0.AllCasePaths, AnyCasePath<τ_0_0, τ_1_0>>, @guaranteed Case<τ_0_0>) -> @owned Case<τ_1_0>, getter @$s9CasePaths0A0V13dynamicMemberACyqd__Gs7KeyPathCy03AllaB0QzAA03AnyaF0Vyxqd__GG_tcAA0A8PathableRzluipACy26swift_case_paths_benchmark3FooOGAqO4Foo2OTK : $@convention(thin) (@in_guaranteed Case<Foo>, UnsafeRawPointer) -> @out Case<Foo2>, indices [%$0 : $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>> : $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>], indices_equals @$ss7KeyPathCy26swift_case_paths_benchmark3FooO12AllCasePathsV0iJ003AnyiB0VyAeC4Foo2OGGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$ss7KeyPathCy26swift_case_paths_benchmark3FooO12AllCasePathsV0iJ003AnyiB0VyAeC4Foo2OGGTh : $@convention(thin) (UnsafeRawPointer) -> Int, external #Case.subscript<Foo, Foo2>) (%13) // user: %15
  %15 = upcast %14 : $KeyPath<Case<Foo>, Case<Foo2>> to $PartialKeyPath<Case<Foo>> // user: %17
  %16 = alloc_stack $PartialKeyPath<Case<Foo>>    // users: %22, %20, %17
  store %15 to [init] %16 : $*PartialKeyPath<Case<Foo>> // id: %17
  %18 = begin_access [modify] [unknown] %5 : $*Array<PartialKeyPath<Case<Foo>>> // users: %21, %20
  // function_ref Array.append(_:)
  %19 = function_ref @$sSa6appendyyxnF : $@convention(method) <τ_0_0> (@in τ_0_0, @inout Array<τ_0_0>) -> () // user: %20
  %20 = apply %19<PartialKeyPath<Case<Foo>>>(%16, %18) : $@convention(method) <τ_0_0> (@in τ_0_0, @inout Array<τ_0_0>) -> ()
  end_access %18 : $*Array<PartialKeyPath<Case<Foo>>> // id: %21
  dealloc_stack %16 : $*PartialKeyPath<Case<Foo>> // id: %22
  %23 = unchecked_addr_cast %0 : $*@_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __ to $*IndexingIterator<Array<PartialKeyPath<Case<Foo>>>> // user: %30
  %24 = begin_access [read] [unknown] %5 : $*Array<PartialKeyPath<Case<Foo>>> // users: %26, %25
  %25 = load [copy] %24 : $*Array<PartialKeyPath<Case<Foo>>> // user: %28
  end_access %24 : $*Array<PartialKeyPath<Case<Foo>>> // id: %26
  %27 = alloc_stack $Array<PartialKeyPath<Case<Foo>>> // users: %31, %30, %28
  store %25 to [init] %27 : $*Array<PartialKeyPath<Case<Foo>>> // id: %28
  // function_ref Collection<>.makeIterator()
  %29 = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in τ_0_0) -> @out IndexingIterator<τ_0_0> // user: %30
  %30 = apply %29<[PartialKeyPath<Case<Foo>>]>(%23, %27) : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in τ_0_0) -> @out IndexingIterator<τ_0_0>
  dealloc_stack %27 : $*Array<PartialKeyPath<Case<Foo>>> // id: %31
  end_borrow %4 : ${ var Array<PartialKeyPath<Case<Foo>>> } // id: %32
  destroy_value %3 : ${ var Array<PartialKeyPath<Case<Foo>>> } // id: %33
  %34 = tuple ()                                  // user: %35
  return %34 : $()                                // id: %35
} // end sil function '$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF'

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Users/hiroshi/Library/Developer/Toolchains/swift-5.10-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/Common.swift -primary-file /Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/Foo.swift /Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/main.swift -emit-dependencies-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/swift_case_paths_benchmark.build/Foo.d -emit-reference-dependencies-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/swift_case_paths_benchmark.build/Foo.swiftdeps -target arm64-apple-macosx10.15 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -I /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Users/hiroshi/Library/Developer/Toolchains/swift-5.10-RELEASE.xctoolchain/usr/bin/swift-driver -entry-point-function-name swift_case_paths_benchmark_main -load-plugin-executable /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/CasePathsMacros#CasePathsMacros -external-plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-plugin-server -enable-experimental-feature StrictConcurrency -empty-abi-descriptor -resource-dir /Users/hiroshi/Library/Developer/Toolchains/swift-5.10-RELEASE.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name swift_case_paths_benchmark -package-name swift_case_paths -target-sdk-version 14.0 -target-sdk-name macosx14.0 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-5.10-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-5.10-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/swift_case_paths_benchmark.build/Foo.swift.o -index-store-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/index/store -index-system-modules
1.  Apple Swift version 5.10 (swift-5.10-RELEASE)
2.  Compiling with the current language version
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/Foo.swift")
4.  While silgen emitFunction SIL function "@$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF".
 for 'makeIterator()' (at @__swiftmacro_26swift_case_paths_benchmark3Foo12CasePathablefMm_.swift:19:12)
5.  While verifying SIL function "@$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF".
 for 'makeIterator()' (at @__swiftmacro_26swift_case_paths_benchmark3Foo12CasePathablefMm_.swift:19:12)
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           0x0000000105935558 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105934944 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000105935b94 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x0000000188cef584 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000188cbec20 pthread_kill + 288
5  libsystem_c.dylib        0x0000000188bcba30 abort + 180
6  swift-frontend           0x000000010198a4f0 swift::SILOptions::~SILOptions() + 0
7  swift-frontend           0x000000010198b4fc (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 2772
8  swift-frontend           0x0000000101986c54 swift::SILFunction::verify(swift::SILPassManager*, bool, bool, bool) const + 204
9  swift-frontend           0x00000001010b67a8 swift::Lowering::SILGenModule::postEmitFunction(swift::SILDeclRef, swift::SILFunction*) + 240
10 swift-frontend           0x00000001010b6064 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6104
11 swift-frontend           0x00000001010b6cd8 swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 204
12 swift-frontend           0x00000001010b4874 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 164
13 swift-frontend           0x000000010119fac8 (anonymous namespace)::SILGenType::visitFuncDecl(swift::FuncDecl*) + 28
14 swift-frontend           0x000000010119cb94 (anonymous namespace)::SILGenType::emitType() + 248
15 swift-frontend           0x000000010119cb74 (anonymous namespace)::SILGenType::emitType() + 216
16 swift-frontend           0x000000010119ca90 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
17 swift-frontend           0x00000001010b9328 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 984
18 swift-frontend           0x000000010118f9a0 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&) + 148
19 swift-frontend           0x00000001010bc688 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 396
20 swift-frontend           0x00000001010b9c7c swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 92
21 swift-frontend           0x0000000100b06f90 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 572
22 swift-frontend           0x0000000100b170c8 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
23 swift-frontend           0x0000000100b093cc performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 748
24 swift-frontend           0x0000000100b0843c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2096
25 swift-frontend           0x00000001009d0858 swift::mainEntry(int, char const**) + 2160
26 dyld                     0x00000001889360e0 start + 2360

5.9.2

~/Library/Developer/Toolchains/swift-5.9.2-RELEASE.xctoolchain/usr/bin/swift test
...
public class KeyPath<Root, Value> : PartialKeyPath<Root> {
             ^
indirect result type mismatch!
  argument: %0 = argument of bb0 : $*@_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __ // user: %23
  expected: $*IndexingIterator<Array<PartialKeyPath<Case<Foo>>>>
SIL verification failed: entry point argument types do not match function type: matched
In function:
// Foo.AllCasePaths.makeIterator()
sil [ossa] @$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF : $@convention(method) (Foo.AllCasePaths) -> @out @_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __ {
// %0 "$return_value"                             // user: %23
// %1 "self"                                      // user: %2
bb0(%0 : $*@_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __, %1 : $Foo.AllCasePaths):
  debug_value %1 : $Foo.AllCasePaths, let, name "self", argno 1, implicit // id: %2
  %3 = alloc_box ${ var Array<PartialKeyPath<Case<Foo>>> }, var, name "allCasePaths" // users: %33, %4
  %4 = begin_borrow [lexical] %3 : ${ var Array<PartialKeyPath<Case<Foo>>> } // users: %32, %5
  %5 = project_box %4 : ${ var Array<PartialKeyPath<Case<Foo>>> }, 0 // users: %24, %18, %12
  %6 = integer_literal $Builtin.Word, 0           // user: %8
  // function_ref _allocateUninitializedArray<A>(_:)
  %7 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %8
  %8 = apply %7<PartialKeyPath<Case<Foo>>>(%6) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %9
  (%9, %10) = destructure_tuple %8 : $(Array<PartialKeyPath<Case<Foo>>>, Builtin.RawPointer) // users: %12, %11
  %11 = pointer_to_address %10 : $Builtin.RawPointer to [strict] $*PartialKeyPath<Case<Foo>>
  store %9 to [init] %5 : $*Array<PartialKeyPath<Case<Foo>>> // id: %12
  %13 = keypath $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>, (root $Foo.AllCasePaths; gettable_property $AnyCasePath<Foo, Foo2>,  id @$s26swift_case_paths_benchmark3FooO12AllCasePathsV3foo0gH003AnyG4PathVyAcA4Foo2OGvg : $@convention(method) (Foo.AllCasePaths) -> @owned AnyCasePath<Foo, Foo2>, getter @$s26swift_case_paths_benchmark3FooO12AllCasePathsV3foo0gH003AnyG4PathVyAcA4Foo2OGvpAETK : $@convention(thin) (@in_guaranteed Foo.AllCasePaths) -> @out AnyCasePath<Foo, Foo2>) // user: %14
  %14 = keypath $KeyPath<Case<Foo>, Case<Foo2>>, (root $Case<Foo>; gettable_property $Case<Foo2>,  id @$s9CasePaths0A0V13dynamicMemberACyqd__Gs7KeyPathCy03AllaB0QzAA03AnyaF0Vyxqd__GG_tcAA0A8PathableRzluig : $@convention(method) <τ_0_0 where τ_0_0 : CasePathable><τ_1_0> (@guaranteed KeyPath<τ_0_0.AllCasePaths, AnyCasePath<τ_0_0, τ_1_0>>, @guaranteed Case<τ_0_0>) -> @owned Case<τ_1_0>, getter @$s9CasePaths0A0V13dynamicMemberACyqd__Gs7KeyPathCy03AllaB0QzAA03AnyaF0Vyxqd__GG_tcAA0A8PathableRzluipACy26swift_case_paths_benchmark3FooOGAqO4Foo2OTK : $@convention(thin) (@in_guaranteed Case<Foo>, UnsafeRawPointer) -> @out Case<Foo2>, indices [%$0 : $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>> : $KeyPath<Foo.AllCasePaths, AnyCasePath<Foo, Foo2>>], indices_equals @$ss7KeyPathCy26swift_case_paths_benchmark3FooO12AllCasePathsV0iJ003AnyiB0VyAeC4Foo2OGGTH : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @$ss7KeyPathCy26swift_case_paths_benchmark3FooO12AllCasePathsV0iJ003AnyiB0VyAeC4Foo2OGGTh : $@convention(thin) (UnsafeRawPointer) -> Int, external #Case.subscript<Foo, Foo2>) (%13) // user: %15
  %15 = upcast %14 : $KeyPath<Case<Foo>, Case<Foo2>> to $PartialKeyPath<Case<Foo>> // user: %17
  %16 = alloc_stack $PartialKeyPath<Case<Foo>>    // users: %22, %20, %17
  store %15 to [init] %16 : $*PartialKeyPath<Case<Foo>> // id: %17
  %18 = begin_access [modify] [unknown] %5 : $*Array<PartialKeyPath<Case<Foo>>> // users: %21, %20
  // function_ref Array.append(_:)
  %19 = function_ref @$sSa6appendyyxnF : $@convention(method) <τ_0_0> (@in τ_0_0, @inout Array<τ_0_0>) -> () // user: %20
  %20 = apply %19<PartialKeyPath<Case<Foo>>>(%16, %18) : $@convention(method) <τ_0_0> (@in τ_0_0, @inout Array<τ_0_0>) -> ()
  end_access %18 : $*Array<PartialKeyPath<Case<Foo>>> // id: %21
  dealloc_stack %16 : $*PartialKeyPath<Case<Foo>> // id: %22
  %23 = unchecked_addr_cast %0 : $*@_opaqueReturnTypeOf("$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF", 0) __ to $*IndexingIterator<Array<PartialKeyPath<Case<Foo>>>> // user: %30
  %24 = begin_access [read] [unknown] %5 : $*Array<PartialKeyPath<Case<Foo>>> // users: %26, %25
  %25 = load [copy] %24 : $*Array<PartialKeyPath<Case<Foo>>> // user: %28
  end_access %24 : $*Array<PartialKeyPath<Case<Foo>>> // id: %26
  %27 = alloc_stack $Array<PartialKeyPath<Case<Foo>>> // users: %31, %30, %28
  store %25 to [init] %27 : $*Array<PartialKeyPath<Case<Foo>>> // id: %28
  // function_ref Collection<>.makeIterator()
  %29 = function_ref @$sSlss16IndexingIteratorVyxG0B0RtzrlE04makeB0ACyF : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in τ_0_0) -> @out IndexingIterator<τ_0_0> // user: %30
  %30 = apply %29<[PartialKeyPath<Case<Foo>>]>(%23, %27) : $@convention(method) <τ_0_0 where τ_0_0 : Collection, τ_0_0.Iterator == IndexingIterator<τ_0_0>> (@in τ_0_0) -> @out IndexingIterator<τ_0_0>
  dealloc_stack %27 : $*Array<PartialKeyPath<Case<Foo>>> // id: %31
  end_borrow %4 : ${ var Array<PartialKeyPath<Case<Foo>>> } // id: %32
  destroy_value %3 : ${ var Array<PartialKeyPath<Case<Foo>>> } // id: %33
  %34 = tuple ()                                  // user: %35
  return %34 : $()                                // id: %35
} // end sil function '$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF'

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Users/hiroshi/Library/Developer/Toolchains/swift-5.9.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/Common.swift -primary-file /Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/Foo.swift /Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/main.swift -emit-dependencies-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/swift_case_paths_benchmark.build/Foo.d -emit-reference-dependencies-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/swift_case_paths_benchmark.build/Foo.swiftdeps -target arm64-apple-macosx10.15 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -I /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Users/hiroshi/Library/Developer/Toolchains/swift-5.9.2-RELEASE.xctoolchain/usr/bin/swift-driver -entry-point-function-name swift_case_paths_benchmark_main -load-plugin-executable /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/CasePathsMacros#CasePathsMacros -external-plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-plugin-server -enable-experimental-feature StrictConcurrency -empty-abi-descriptor -resource-dir /Users/hiroshi/Library/Developer/Toolchains/swift-5.9.2-RELEASE.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -module-name swift_case_paths_benchmark -package-name swift_case_paths -target-sdk-version 14.0 -target-sdk-name macosx14.0 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-5.9.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-5.9.2-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/swift_case_paths_benchmark.build/Foo.swift.o -index-store-path /Users/hiroshi/dev/devin-1441/swift-case-paths/.build/arm64-apple-macosx/debug/index/store -index-system-modules
1.  Apple Swift version 5.9.2 (swift-5.9.2-RELEASE)
2.  Compiling with the current language version
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/hiroshi/dev/devin-1441/swift-case-paths/Sources/swift-case-paths-benchmark/Foo.swift")
4.  While silgen emitFunction SIL function "@$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF".
 for 'makeIterator()' (at @__swiftmacro_26swift_case_paths_benchmark3Foo12CasePathablefMm_.swift:19:12)
5.  While verifying SIL function "@$s26swift_case_paths_benchmark3FooO12AllCasePathsV12makeIteratorQryF".
 for 'makeIterator()' (at @__swiftmacro_26swift_case_paths_benchmark3Foo12CasePathablefMm_.swift:19:12)
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           0x00000001097c5584 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001097c4928 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001097c5bc4 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x0000000188cef584 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000188cbec20 pthread_kill + 288
5  libsystem_c.dylib        0x0000000188bcba30 abort + 180
6  swift-frontend           0x00000001058b9ed0 (anonymous namespace)::SILVerifier::_require(bool, llvm::Twine const&, std::__1::function<void ()> const&) + 1476
7  swift-frontend           0x00000001058baf74 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 2628
8  swift-frontend           0x00000001058b65a8 swift::SILFunction::verify(bool, bool, bool) const + 200
9  swift-frontend           0x00000001050345bc swift::Lowering::SILGenModule::postEmitFunction(swift::SILDeclRef, swift::SILFunction*) + 236
10 swift-frontend           0x0000000105032d3c swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 3984
11 swift-frontend           0x00000001050354a4 emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef) + 200
12 swift-frontend           0x0000000105031d94 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 164
13 swift-frontend           0x0000000105114c58 (anonymous namespace)::SILGenType::visitFuncDecl(swift::FuncDecl*) + 28
14 swift-frontend           0x0000000105111b54 (anonymous namespace)::SILGenType::emitType() + 140
15 swift-frontend           0x0000000105114788 swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 96
16 swift-frontend           0x0000000105111b54 (anonymous namespace)::SILGenType::emitType() + 140
17 swift-frontend           0x0000000105111abc swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
18 swift-frontend           0x0000000105037448 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1004
19 swift-frontend           0x000000010510614c 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&) + 148
20 swift-frontend           0x000000010503b290 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 396
21 swift-frontend           0x000000010503870c swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 100
22 swift-frontend           0x0000000104b12890 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 524
23 swift-frontend           0x0000000104b21888 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
24 swift-frontend           0x0000000104b14458 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2848
25 swift-frontend           0x0000000104999354 swift::mainEntry(int, char const**) + 3256
26 dyld                     0x00000001889360e0 start + 2360
[307/348] Compiling swift_case_paths_benchmark main.swift
error: fatalError
stephencelis commented 3 months ago

I was able to reduce the issue to this line: https://github.com/pointfreeco/swift-case-paths/pull/159/commits/51baf3c1e862bb7964e99ebce915d2f9cc92d66c

The workaround:

-public func makeIterator() -> some IteratorProtocol<PartialCaseKeyPath<\(enumName)>> {
+public func makeIterator() -> IndexingIterator<[PartialCaseKeyPath<\(enumName)>]> {

So it appears to be an issue with a macro generating opaque return types.

I unfortunately haven't had a ton of luck reproducing the issue in a fresh macro project.