pointfreeco / swift-case-paths

🧰 Case paths extends the key path hierarchy to enum cases.
https://www.pointfree.co/collections/enums-and-structs/case-paths
MIT License
902 stars 101 forks source link

1.5.0 crashes Swift 6 nightly compiler on Linux #180

Closed finestructure closed 1 month ago

finestructure commented 1 month ago

We've had to pin swift-case-paths to 1.4.2, because 1.5.0 crashes the compiler with recent Swift 6 toolchains:

❯ git clone https://github.com/pointfreeco/swift-case-paths.git && cd swift-case-paths
❯ git checkout 1.5.0
❯ docker run --rm -v $PWD:/host -w /host swiftlang/swift@sha256:eaf2f6940b2406ee3c0c5e4264f193e886b4d5e3a973bdf1cbaf94962822366c swift build
Fetching https://github.com/apple/swift-docc-symbolkit
Fetching https://github.com/pointfreeco/xctest-dynamic-overlay
...
[261/263] Write Objects.LinkFileList
[262/263] Linking CasePathsMacros-tool
error: compile command failed due to signal 6 (use -v to see invocation)
swift-frontend: /home/build-user/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = swift::BoundGenericType, From = swift::TypeBase]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /usr/bin/swift-frontend -frontend -c /host/Sources/CasePaths/AnyCasePath.swift /host/Sources/CasePaths/CasePathIterable.swift /host/Sources/CasePaths/CasePathReflectable.swift /host/Sources/CasePaths/CasePathable.swift /host/Sources/CasePaths/EnumReflection.swift /host/Sources/CasePaths/Internal/Deprecations.swift /host/Sources/CasePaths/Internal/LockIsolated.swift /host/Sources/CasePaths/Internal/OpenExistential.swift /host/Sources/CasePaths/Internal/TypeName.swift /host/Sources/CasePaths/Internal/UncheckedSendable.swift /host/Sources/CasePaths/Macros.swift /host/Sources/CasePaths/Never+CasePathable.swift -primary-file /host/Sources/CasePaths/Optional+CasePathable.swift /host/Sources/CasePaths/Result+CasePathable.swift /host/Sources/CasePaths/XCTestSupport.swift -emit-dependencies-path /host/.build/aarch64-unknown-linux-gnu/debug/CasePaths.build/Optional+CasePathable.d -emit-reference-dependencies-path /host/.build/aarch64-unknown-linux-gnu/debug/CasePaths.build/Optional+CasePathable.swiftdeps -target aarch64-unknown-linux-gnu -Xllvm -aarch64-use-tbi -disable-objc-interop -I /host/.build/aarch64-unknown-linux-gnu/debug/Modules -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /host/.build/aarch64-unknown-linux-gnu/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -load-plugin-executable /host/.build/aarch64-unknown-linux-gnu/debug/CasePathsMacros-tool#CasePathsMacros -empty-abi-descriptor -resource-dir /usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /host -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name CasePaths -package-name host -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -parse-as-library -o /host/.build/aarch64-unknown-linux-gnu/debug/CasePaths.build/Optional+CasePathable.swift.o -index-store-path /host/.build/aarch64-unknown-linux-gnu/debug/index/store -index-system-modules
1.  Swift version 6.0-dev (LLVM a41678ee19c803d, Swift ce381e7b159dfac)
2.  Compiling with the current language version
3.  While evaluating request TypeCheckSourceFileRequest(source_file "/host/Sources/CasePaths/Optional+CasePathable.swift")
4.  While evaluating request TypeCheckFunctionBodyRequest(CasePaths.(file).Optional extension.AllCasePaths._@/host/Sources/CasePaths/Optional+CasePathable.swift:4:70)
5.  While type-checking statement at [/host/Sources/CasePaths/Optional+CasePathable.swift:4:70 - line:9:5] RangeText="{
      switch root {
      case .none: return \.none
      case .some: return \.some
      }
    "
6.  While type-checking statement at [/host/Sources/CasePaths/Optional+CasePathable.swift:5:7 - line:8:7] RangeText="switch root {
      case .none: return \.none
      case .some: return \.some
      "
7.  While type-checking statement at [/host/Sources/CasePaths/Optional+CasePathable.swift:6:19 - line:6:28] RangeText="return \."
8.  While type-checking statement at [/host/Sources/CasePaths/Optional+CasePathable.swift:6:19 - line:6:28] RangeText="return \."
9.  While type-checking-target starting at /host/Sources/CasePaths/Optional+CasePathable.swift:6:26
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  0x0000aaaac3959e48
1  swift-frontend  0x0000aaaac3957e3c
2  swift-frontend  0x0000aaaac395a554
3  linux-vdso.so.1 0x0000ffffa87f97a0 __kernel_rt_sigreturn + 0
4  libc.so.6       0x0000ffffa6bdf200
5  libc.so.6       0x0000ffffa6b9a67c raise + 28
6  libc.so.6       0x0000ffffa6b87130 abort + 228
7  libc.so.6       0x0000ffffa6b93fd0
8  libc.so.6       0x0000ffffa6b94040 __assert_perror_fail + 0
9  swift-frontend  0x0000aaaabe8009c0
10 swift-frontend  0x0000aaaabe7eb920
11 swift-frontend  0x0000aaaabebda5a4
12 swift-frontend  0x0000aaaabebda4b4
13 swift-frontend  0x0000aaaabe7e1e98
14 swift-frontend  0x0000aaaabe7e13b8
15 swift-frontend  0x0000aaaabe681b78
16 swift-frontend  0x0000aaaabe7639a0
17 swift-frontend  0x0000aaaabe76358c
18 swift-frontend  0x0000aaaabe75f0e0
19 swift-frontend  0x0000aaaabe76364c
20 swift-frontend  0x0000aaaabe761388
21 swift-frontend  0x0000aaaabe764274
22 swift-frontend  0x0000aaaabe76358c
23 swift-frontend  0x0000aaaabe75f0e0
24 swift-frontend  0x0000aaaabe76364c
25 swift-frontend  0x0000aaaabe761388
26 swift-frontend  0x0000aaaabe760a18
27 swift-frontend  0x0000aaaabe760600
28 swift-frontend  0x0000aaaabecfaf7c
29 swift-frontend  0x0000aaaabec5a558
30 swift-frontend  0x0000aaaabedb4e5c
31 swift-frontend  0x0000aaaabe7a616c
32 swift-frontend  0x0000aaaabe7a811c
33 swift-frontend  0x0000aaaabe7a6054
34 swift-frontend  0x0000aaaabd56c7dc
35 swift-frontend  0x0000aaaabd564828
36 swift-frontend  0x0000aaaabd5647bc
37 swift-frontend  0x0000aaaabd283f7c
38 swift-frontend  0x0000aaaabd27947c
39 swift-frontend  0x0000aaaabd278684
40 swift-frontend  0x0000aaaabd0668a0
41 libc.so.6       0x0000ffffa6b873fc
42 libc.so.6       0x0000ffffa6b874cc __libc_start_main + 152
43 swift-frontend  0x0000aaaabd065ab0

swiftlang/swift@sha256:eaf2f6940b2406ee3c0c5e4264f193e886b4d5e3a973bdf1cbaf94962822366c is swift-6.0-DEVELOPMENT-SNAPSHOT-2024-07-13-a, but it also crashes with last week's snapshot.

I can post this against Swift if you prefer but I thought I'd let you two know first in case you have more insight into what might be going on!

stephencelis commented 1 month ago

We may have jumped on Swift 6 language mode prematurely. Would love to support all the sendability improvements coming, but looks like there's a regression here: https://github.com/swiftlang/swift/issues/75244

Will see if there's anything we can do in the library, or worst case we'll disable Swift 6 language mode for now.

finestructure commented 1 month ago

1.5.1 fixes the compiler crash in our build, thanks for the quick fix!