Skip to content

Compiler crash on a rather simple extension of AsyncSequence #85821

@Ky-MLB

Description

@Ky-MLB

Description

The protocol extension in the Reproduction section below always crashes the toolchain when building for watchOS.

I think it has something to do with the @available annotation, but it also compiles successfully if I leave that annotation there and replace commit() with a dummy function. Only the combination of these two causes the crash.

Reproduction

@available(iOS, introduced: 18.0)
internal extension AsyncSequence {
    func collect() async throws(Failure) -> [Element] {
        try await reduce(into: [Element]()) { $0.append($1) }
    }
}

Expected behavior

The Swift compiler doesn't crash, and the extension is built as described

Environment

swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx26.0

Additional information

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/ky/Desktop/AsyncSequenceExtensionCrash/Sources/AsyncSequenceExtensionCrash/AsyncSequenceExtensionCrash.swift -emit-dependencies-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.d -emit-const-values-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.swiftconstvalues -emit-reference-dependencies-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.swiftdeps -serialize-diagnostics-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.dia -target arm64_32-apple-watchos11.0 -load-resolved-plugin /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/usr/lib/swift/host/plugins/libSwiftMacros.dylib#/Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/usr/bin/swift-plugin-server#SwiftMacros -disable-implicit-swift-modules -Xcc -fno-implicit-modules -Xcc -fno-implicit-module-maps -explicit-swift-module-map-file /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash-dependencies-1.json -enable-objc-interop -sdk /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS26.0.sdk -I /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Products/Debug-watchos -Isystem /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/usr/lib -F /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Products/Debug-watchos -F /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/Library/Frameworks -F /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS26.0.sdk/Developer/Library/Frameworks -no-color-diagnostics -Xcc -fno-color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=5 -module-cache-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -swift-version 6 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -const-gather-protocols-file /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash_const_extract_protocols.json -enable-experimental-feature DebugDescriptionMacro -empty-abi-descriptor -validate-clang-modules-once -clang-build-session-file /Users/ky/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/ky/Desktop/AsyncSequenceExtensionCrash/.swiftpm/xcode -enable-anonymous-context-mangled-names -file-compilation-dir /Users/ky/Desktop/AsyncSequenceExtensionCrash/.swiftpm/xcode -Xcc -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -Xcc -ivfsstatcache -Xcc /Users/ky/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/watchos26.0-23R351-d7699839d656960b3703d6fe383cf8b1.sdkstatcache -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Products/Debug-watchos/include -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/DerivedSources-normal/arm64_32 -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/DerivedSources/arm64_32 -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -no-auto-bridging-header-chaining -module-name AsyncSequenceExtensionCrash -package-name asyncsequenceextensioncrash -frontend-parseable-output -disable-clang-spi -target-sdk-version 26.0 -target-sdk-name watchos26.0 -clang-target arm64_32-apple-watchos26.0 -in-process-plugin-server-path /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -parse-as-library -o /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.o -index-unit-output-path /AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.o -index-store-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Index.noindex/DataStore -index-system-modules
1.	Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "/Users/ky/Desktop/AsyncSequenceExtensionCrash/Sources/AsyncSequenceExtensionCrash/AsyncSequenceExtensionCrash.swift")
4.	While emitting IR SIL function "@$sSci27AsyncSequenceExtensionCrashE7collectSay7ElementQzGyYa7FailureQzYKF".
 for 'collect()' (at /Users/ky/Desktop/AsyncSequenceExtensionCrash/Sources/AsyncSequenceExtensionCrash/AsyncSequenceExtensionCrash.swift:13:5)
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           0x000000010b2d9bcc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010b2d755c llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010b2da1f8 SignalHandler(int, __siginfo*, void*) + 344
3  libsystem_platform.dylib 0x0000000196d63744 _sigtramp + 56
4  swift-frontend           0x0000000105448d3c swift::irgen::emitClassExistentialContainer(swift::irgen::IRGenFunction&, swift::irgen::Explosion&, swift::SILType, llvm::Value*, swift::CanType, swift::SILType, llvm::ArrayRef<swift::ProtocolConformanceRef>) + 676
5  swift-frontend           0x00000001055e522c (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 58228
6  swift-frontend           0x00000001055d57e8 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 15996
7  swift-frontend           0x00000001055d1540 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2836
8  swift-frontend           0x00000001053e5c44 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) + 2176
9  swift-frontend           0x000000010557f6a0 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 4296
10 swift-frontend           0x00000001055d02ec swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 180
11 swift-frontend           0x0000000105588d44 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 856
12 swift-frontend           0x00000001055823b8 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 176
13 swift-frontend           0x0000000104f19130 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156
14 swift-frontend           0x0000000104f1474c performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 2108
15 swift-frontend           0x0000000104f1374c swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1032
16 swift-frontend           0x0000000104f16a7c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764
17 swift-frontend           0x0000000104f1568c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3580
18 swift-frontend           0x0000000104e96c6c swift::mainEntry(int, char const**) + 5412
19 dyld                     0x0000000196991d54 start + 7184
Failed frontend command:
/Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/ky/Desktop/AsyncSequenceExtensionCrash/Sources/AsyncSequenceExtensionCrash/AsyncSequenceExtensionCrash.swift -emit-dependencies-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.d -emit-const-values-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.swiftconstvalues -emit-reference-dependencies-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.swiftdeps -serialize-diagnostics-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.dia -target arm64_32-apple-watchos11.0 -load-resolved-plugin /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/usr/lib/swift/host/plugins/libSwiftMacros.dylib\#/Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/usr/bin/swift-plugin-server\#SwiftMacros -disable-implicit-swift-modules -Xcc -fno-implicit-modules -Xcc -fno-implicit-module-maps -explicit-swift-module-map-file /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash-dependencies-1.json -enable-objc-interop -sdk /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS26.0.sdk -I /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Products/Debug-watchos -Isystem /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/usr/lib -F /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Products/Debug-watchos -F /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/Library/Frameworks -F /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS26.0.sdk/Developer/Library/Frameworks -no-color-diagnostics -Xcc -fno-color-diagnostics -enable-testing -g -debug-info-format\=dwarf -dwarf-version\=5 -module-cache-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -swift-version 6 -enforce-exclusivity\=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -const-gather-protocols-file /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash_const_extract_protocols.json -enable-experimental-feature DebugDescriptionMacro -empty-abi-descriptor -validate-clang-modules-once -clang-build-session-file /Users/ky/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/ky/Desktop/AsyncSequenceExtensionCrash/.swiftpm/xcode -enable-anonymous-context-mangled-names -file-compilation-dir /Users/ky/Desktop/AsyncSequenceExtensionCrash/.swiftpm/xcode -Xcc -D_LIBCPP_HARDENING_MODE\=_LIBCPP_HARDENING_MODE_DEBUG -Xcc -ivfsstatcache -Xcc /Users/ky/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/watchos26.0-23R351-d7699839d656960b3703d6fe383cf8b1.sdkstatcache -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Products/Debug-watchos/include -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/DerivedSources-normal/arm64_32 -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/DerivedSources/arm64_32 -Xcc -I/Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG\=1 -no-auto-bridging-header-chaining -module-name AsyncSequenceExtensionCrash -package-name asyncsequenceextensioncrash -frontend-parseable-output -disable-clang-spi -target-sdk-version 26.0 -target-sdk-name watchos26.0 -clang-target arm64_32-apple-watchos26.0 -in-process-plugin-server-path /Applications/Xcode-26.0.0-release-candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -parse-as-library -o /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Build/Intermediates.noindex/AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.o -index-unit-output-path /AsyncSequenceExtensionCrash.build/Debug-watchos/AsyncSequenceExtensionCrash.build/Objects-normal/arm64_32/AsyncSequenceExtensionCrash.o -index-store-path /Users/ky/Library/Developer/Xcode/DerivedData/AsyncSequenceExtensionCrash-elbjlchnbozdnudelcownwmwffwn/Index.noindex/DataStore -index-system-modules
Command SwiftCompile failed with a nonzero exit code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions