swiftlang / swift

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

Compiler crash compiling AsyncExtensions with 6.0.2 toolchain, but not Xcode 16.1 #77315

Open lhoward opened 4 weeks ago

lhoward commented 4 weeks ago

Description

Seeing a crash compiling AsyncExtensions with Swift 6.0.2 on Android.

OK, interestingly I see this targeting macOS with the Swift 6.0.2 toolchain from swift.org, but not Xcode 16.1.

Reproduction

{
    let asyncBufferedChannel = AsyncBufferedChannel<Element>()

    let (terminalState, current) = self.state.withCriticalRegion { state -> (Termination?, Element) in
      (state.terminalState, state.current)
    }

    if let terminalState = terminalState, terminalState.isFinished {
      asyncBufferedChannel.finish()
      return (asyncBufferedChannel.makeAsyncIterator(), {})
    }

    asyncBufferedChannel.send(current)

    let consumerId = self.state.withCriticalRegion { state -> Int in
      state.ids += 1
      state.channels[state.ids] = asyncBufferedChannel
      return state.ids
    }

    let unregister = { @Sendable [state] in
      state.withCriticalRegion { state in
        state.channels[consumerId] = nil
      }
    }

    return (asyncBufferedChannel.makeAsyncIterator(), unregister)

Stack dump

Assertion failed: (!firstType->hasTypeVariable()), function checkRequirementsImpl, file Requirement.cpp, line 274.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncChannels/AsyncBufferedChannel.swift -primary-file /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncChannels/AsyncThrowingBufferedChannel.swift -primary-file /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift -primary-file /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncPassthroughSubject.swift -primary-file /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncReplaySubject.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncSubject.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncThrowingCurrentValueSubject.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncThrowingPassthroughSubject.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncThrowingReplaySubject.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/Streamed.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Merge/AsyncMerge2Sequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Merge/AsyncMerge3Sequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Merge/AsyncMergeSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Merge/MergeStateMachine.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/WithLatestFrom/AsyncWithLatestFrom2Sequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/WithLatestFrom/AsyncWithLatestFromSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/AsyncZip2Sequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/AsyncZip3Sequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/AsyncZipSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/Zip2Runtime.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/Zip2StateMachine.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/Zip3Runtime.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/Zip3StateMachine.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/ZipRuntime.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Combiners/Zip/ZipStateMachine.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Common/Termination.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Creators/AsyncEmptySequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Creators/AsyncFailSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Creators/AsyncJustSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Creators/AsyncLazySequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Creators/AsyncStream+Pipe.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Creators/AsyncThrowingJustSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Creators/AsyncTimerSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncHandleEventsSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncMapToResultSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncMulticastSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncPrependSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncScanSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncSequence+Assign.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncSequence+Collect.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncSequence+EraseToAnyAsyncSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncSequence+FlatMapLatest.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncSequence+Share.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Operators/AsyncSwitchToLatestSequence.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Supporting/Locking.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Supporting/Regulator.swift /Users/lukeh/CVSRoot/AsyncExtensions/Sources/Supporting/Result+ErrorMechanism.swift -supplementary-output-file-map /var/folders/p9/r5c1gcks6_1cy8f6htvb0h8c0000gn/T/TemporaryDirectory.7dcr59/supplementaryOutputs-1 -target aarch64-unknown-linux-android24 -Xllvm -aarch64-use-tbi -disable-objc-interop -sdk /Users/lukeh/Library/org.swift.swiftpm/swift-sdks/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle/swift-6.0.2-release-android-24-sdk/android-27c-sysroot -I /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/Modules -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -empty-abi-descriptor -resource-dir /Users/lukeh/Library/org.swift.swiftpm/swift-sdks/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle/swift-6.0.2-release-android-24-sdk/android-27c-sysroot/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/lukeh/CVSRoot/AsyncExtensions -Xcc --sysroot -Xcc /Users/lukeh/Library/org.swift.swiftpm/swift-sdks/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle/swift-6.0.2-release-android-24-sdk/android-27c-sysroot -Xcc -g -Xcc -fno-omit-frame-pointer -module-name AsyncExtensions -plugin-path /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -parse-as-library -o /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/AsyncExtensions.build/AsyncBufferedChannel.swift.o -o /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/AsyncExtensions.build/AsyncThrowingBufferedChannel.swift.o -o /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/AsyncExtensions.build/AsyncCurrentValueSubject.swift.o -o /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/AsyncExtensions.build/AsyncPassthroughSubject.swift.o -o /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/AsyncExtensions.build/AsyncReplaySubject.swift.o -index-store-path /Users/lukeh/CVSRoot/AsyncExtensions/.build/aarch64-unknown-linux-android24/debug/index/store -index-system-modules
1.  Apple Swift version 6.0.2 (swift-6.0.2-RELEASE)
2.  Compiling with effective version 5.10
3.  While evaluating request TypeCheckSourceFileRequest(source_file "/Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift")
4.  While evaluating request TypeCheckFunctionBodyRequest(AsyncExtensions.(file).AsyncCurrentValueSubject.handleNewConsumer()@/Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift:91:8)
5.  While type-checking statement at [/Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift:91:116 - line:118:3] RangeText="{
    let asyncBufferedChannel = AsyncBufferedChannel<Element>()

    let (terminalState, current) = self.state.withCriticalRegion { state -> (Termination?, Element) in
      (state.terminalState, state.current)
    }

    if let terminalState = terminalState, terminalState.isFinished {
      asyncBufferedChannel.finish()
      return (asyncBufferedChannel.makeAsyncIterator(), {})
    }

    asyncBufferedChannel.send(current)

    let consumerId = self.state.withCriticalRegion { state -> Int in
      state.ids += 1
      state.channels[state.ids] = asyncBufferedChannel
      return state.ids
    }

    let unregister = { @Sendable [state] in
      state.withCriticalRegion { state in
        state.channels[consumerId] = nil
      }
    }

    return (asyncBufferedChannel.makeAsyncIterator(), unregister)
  "
6.  While type-checking declaration 0x119924570 (at /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift:94:5)
7.  While evaluating request PatternBindingEntryRequest((unknown decl), 0)
8.  While type-checking expression at [/Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift:94:36 - line:96:5] RangeText="self.state.withCriticalRegion { state -> (Termination?, Element) in
      (state.terminalState, state.current)
    "
9.  While type-checking-target starting at /Users/lukeh/CVSRoot/AsyncExtensions/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift:94:47
10. While evaluating request ResolveTypeRequest(while resolving type , (Termination?, Element))
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           0x000000010a35d0d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010a35b8a4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010a35d720 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x0000000180f67584 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000180f36c20 pthread_kill + 288
5  libsystem_c.dylib        0x0000000180e43a30 abort + 180
6  libsystem_c.dylib        0x0000000180e42d20 err + 0
7  swift-frontend           0x000000010a8b34b0 checkRequirementsImpl(llvm::ArrayRef<swift::Requirement>, bool) (.cold.9) + 0
8  swift-frontend           0x0000000106757ff4 checkRequirementsImpl(llvm::ArrayRef<swift::Requirement>, bool) + 388
9  swift-frontend           0x000000010656f67c swift::ModuleDecl::checkConformance(swift::Type, swift::ProtocolDecl*, bool) + 76
10 swift-frontend           0x000000010656fc34 conformsToInvertible(swift::CanType, swift::InvertibleProtocolKind) + 344
11 swift-frontend           0x000000010656f9c8 swift::TypeBase::isNoncopyable() + 20
12 swift-frontend           0x000000010620dec0 (anonymous namespace)::TypeResolver::resolveTupleType(swift::TupleTypeRepr*, swift::TypeResolutionOptions) + 716
13 swift-frontend           0x0000000106208454 (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::TypeResolutionOptions) + 812
14 swift-frontend           0x0000000106206f3c evaluateTypeResolution(swift::TypeResolution const*, swift::TypeRepr*, swift::SILTypeResolutionContext*) + 88
15 swift-frontend           0x000000010621cbcc swift::ResolveTypeRequest::OutputType swift::Evaluator::getResultUncached<swift::ResolveTypeRequest, swift::ResolveTypeRequest::OutputType swift::evaluateOrDefault<swift::ResolveTypeRequest>(swift::Evaluator&, swift::ResolveTypeRequest, swift::ResolveTypeRequest::OutputType)::'lambda'()>(swift::ResolveTypeRequest const&, swift::ResolveTypeRequest::OutputType swift::evaluateOrDefault<swift::ResolveTypeRequest>(swift::Evaluator&, swift::ResolveTypeRequest, swift::ResolveTypeRequest::OutputType)::'lambda'()) + 212
16 swift-frontend           0x0000000106206e10 swift::TypeResolution::resolveContextualType(swift::TypeRepr*, swift::DeclContext*, swift::GenericSignature, swift::TypeResolutionOptions, llvm::function_ref<swift::Type (swift::UnboundGenericType*)>, llvm::function_ref<swift::Type (swift::ASTContext&, swift::PlaceholderTypeRepr*)>, llvm::function_ref<swift::Type (swift::Type, swift::PackElementTypeRepr*)>, swift::SILTypeResolutionContext*) + 124
17 swift-frontend           0x0000000105f1039c (anonymous namespace)::ConstraintGenerator::resolveTypeReferenceInExpression(swift::TypeRepr*, swift::TypeResolutionOptions, swift::constraints::ConstraintLocatorBuilder const&) + 208
18 swift-frontend           0x0000000105f0fcf0 (anonymous namespace)::ConstraintGenerator::inferClosureType(swift::ClosureExpr*, bool) + 1280
19 swift-frontend           0x0000000105f0f678 (anonymous namespace)::ConstraintGenerator::visitClosureExpr(swift::ClosureExpr*) + 280
20 swift-frontend           0x0000000105f0ea50 (anonymous namespace)::ConstraintWalker::walkToExprPre(swift::Expr*) + 388
21 swift-frontend           0x0000000106522f18 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 44
22 swift-frontend           0x0000000106527a18 swift::ArgumentList* llvm::function_ref<swift::ArgumentList* (swift::ArgumentList*)>::callback_fn<(anonymous namespace)::Traversal::doIt(swift::ArgumentList*)::'lambda'(swift::ArgumentList*)>(long, swift::ArgumentList*) + 264
23 swift-frontend           0x00000001065278ac swift::ArgumentList* (anonymous namespace)::Traversal::traverse<swift::ArgumentList>(swift::ASTWalker::PreWalkResult<swift::ArgumentList*>, llvm::function_ref<swift::ArgumentList* (swift::ArgumentList*)>, llvm::function_ref<swift::ASTWalker::PostWalkResult<swift::ArgumentList*> (swift::ArgumentList*)>) + 84
24 swift-frontend           0x0000000106524ee8 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 108
25 swift-frontend           0x0000000106522fc8 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 220
26 swift-frontend           0x0000000106522ee0 swift::Expr::walk(swift::ASTWalker&) + 32
27 swift-frontend           0x0000000105f0aca0 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*, swift::DeclContext*) + 120
28 swift-frontend           0x0000000105f09f68 swift::constraints::ConstraintSystem::generateConstraints(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) + 448
29 swift-frontend           0x0000000105f717c0 swift::constraints::ConstraintSystem::solveImpl(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) + 408
30 swift-frontend           0x0000000105f71058 swift::constraints::ConstraintSystem::solve(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) + 160
31 swift-frontend           0x0000000106109b4c swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 312
32 swift-frontend           0x00000001061099bc swift::TypeChecker::typeCheckExpression(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 184
33 swift-frontend           0x000000010610ac74 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, swift::Type, swift::PatternBindingDecl*, unsigned int, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 120
34 swift-frontend           0x000000010610aea8 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, swift::Type, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 248
35 swift-frontend           0x00000001061e8d58 swift::PatternBindingEntryRequest::evaluate(swift::Evaluator&, swift::PatternBindingDecl*, unsigned int) const + 2380
36 swift-frontend           0x00000001065b66a4 swift::PatternBindingEntryRequest::OutputType swift::Evaluator::getResultUncached<swift::PatternBindingEntryRequest, swift::PatternBindingEntryRequest::OutputType swift::evaluateOrDefault<swift::PatternBindingEntryRequest>(swift::Evaluator&, swift::PatternBindingEntryRequest, swift::PatternBindingEntryRequest::OutputType)::'lambda'()>(swift::PatternBindingEntryRequest const&, swift::PatternBindingEntryRequest::OutputType swift::evaluateOrDefault<swift::PatternBindingEntryRequest>(swift::Evaluator&, swift::PatternBindingEntryRequest, swift::PatternBindingEntryRequest::OutputType)::'lambda'()) + 228
37 swift-frontend           0x00000001065843ec swift::PatternBindingDecl::getCheckedPatternBindingEntry(unsigned int) const + 132
38 swift-frontend           0x0000000106152f6c (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 1264
39 swift-frontend           0x0000000106152a68 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 136
40 swift-frontend           0x00000001061dfb24 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 160
41 swift-frontend           0x00000001061de138 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 136
42 swift-frontend           0x00000001061dd88c (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 32
43 swift-frontend           0x00000001061dd5f4 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1356
44 swift-frontend           0x000000010662e084 swift::TypeCheckFunctionBodyRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()>(swift::TypeCheckFunctionBodyRequest const&, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()) + 240
45 swift-frontend           0x000000010659b664 swift::AbstractFunctionDecl::getTypecheckedBody() const + 120
46 swift-frontend           0x00000001066d5340 swift::SourceFile::typeCheckDelayedFunctions() + 104
47 swift-frontend           0x000000010621dff8 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 256
48 swift-frontend           0x000000010621fb50 swift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()>(swift::TypeCheckSourceFileRequest const&, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()) + 232
49 swift-frontend           0x000000010621ded0 swift::performTypeChecking(swift::SourceFile&) + 84
50 swift-frontend           0x00000001050ee70c bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_7>(long, swift::SourceFile&) + 16
51 swift-frontend           0x00000001050e814c swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 76
52 swift-frontend           0x00000001050e80e0 swift::CompilerInstance::performSema() + 76
53 swift-frontend           0x0000000104eb3448 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
54 swift-frontend           0x0000000104ea9678 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
55 swift-frontend           0x0000000104ea8d4c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2344
56 swift-frontend           0x0000000104cbf384 swift::mainEntry(int, char const**) + 3096
57 dyld                     0x0000000180bae0e0 start + 2360

Expected behavior

Compiles OK.

Environment

Failing:

%  /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/bin/swift --version
Apple Swift version 6.0.2 (swift-6.0.2-RELEASE)
Target: arm64-apple-macosx14.0

Succeeding:

% swift --version
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx14.0
lhoward commented 3 weeks ago

Workaround:

diff --git a/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift b/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift
index 5225105..dd5b111 100644
--- a/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift
+++ b/Sources/AsyncSubjects/AsyncCurrentValueSubject.swift
@@ -91,7 +91,7 @@ public final class AsyncCurrentValueSubject<Element>: AsyncSubject where Element
   func handleNewConsumer() -> (iterator: AsyncBufferedChannel<Element>.Iterator, unregister: @Sendable () -> Void) {
     let asyncBufferedChannel = AsyncBufferedChannel<Element>()

-    let (terminalState, current) = self.state.withCriticalRegion { state -> (Termination?, Element) in
+    let (terminalState, current) = self.state.withCriticalRegion { state in
       (state.terminalState, state.current)
     }