Skip to content

Compiler crash when adding async initializer to actor protocol #80406

Open
@davedelong

Description

@davedelong

Description

Adding an async initializer in an extension on an Actor-constrained protocol crashes the compiler. Removing the : Actor constraint on the protocol makes the issue go away. Removing async from the initializer makes the issue go away.

Reproduction

struct Schema { }

protocol Engine: Actor {
	init(schema: Schema) async
}

extension Engine {
	init() async { await self.init(schema: .init()) }
}

Stack dump

0.	Program arguments: /Applications/Xcode16.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret crash.swift -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode16.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -color-diagnostics -new-driver-path /Applications/Xcode16.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode16.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name crash -disable-clang-spi -target-sdk-version 15.2 -target-sdk-name macosx15.2 -external-plugin-path /Applications/Xcode16.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode16.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode16.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode16.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode16.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode16.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins
1.	Apple Swift version 6.0.3 (swiftlang-6.0.3.1.9 clang-1600.0.30.1)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module crash)
4.	While silgen emitValueConstructor SIL function "@$s5crash6EnginePAAExyYacfC".
 for 'init()' (at crash.swift:8:2)
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           0x0000000106312aac llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000106310d00 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106313078 SignalHandler(int) + 292
3  libsystem_platform.dylib 0x000000018d63ade4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018d603f70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018d510908 abort + 128
6  swift-frontend           0x0000000100c45970 swift::Diagnostic::operator=(swift::Diagnostic const&) + 0
7  swift-frontend           0x00000001017287ac swift::Lowering::SILGenFunction::emitMainExecutor(swift::SILLocation) + 0
8  swift-frontend           0x00000001017284bc swift::Lowering::SILGenFunction::emitConstructorPrologActorHop(swift::SILLocation, std::__1::optional<swift::ActorIsolation>) + 84
9  swift-frontend           0x000000010172a984 swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*) + 2256
10 swift-frontend           0x00000001016d67f4 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 7596
11 swift-frontend           0x00000001016d73cc swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 216
12 swift-frontend           0x00000001016d8684 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 724
13 swift-frontend           0x000000010182bb04 swift::ASTVisitor<SILGenExtension, void, void, void, void, void, void>::visit(swift::Decl*) + 372
14 swift-frontend           0x00000001018280f8 SILGenExtension::emitExtension(swift::ExtensionDecl*) + 424
15 swift-frontend           0x00000001016d46d4 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 264
16 swift-frontend           0x00000001016db048 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1804
17 swift-frontend           0x000000010181193c 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&) + 196
18 swift-frontend           0x00000001016dff24 swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 528
19 swift-frontend           0x0000000100cba314 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2828
20 swift-frontend           0x0000000100cbd384 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2944
21 swift-frontend           0x0000000100cbbbc4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3572
22 swift-frontend           0x0000000100c42a6c swift::mainEntry(int, char const**) + 3680
23 dyld                     0x000000018d284274 start + 2840

Expected behavior

I would expect this to compile correctly.

Environment

% swiftc --version
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.9 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

(Xcode 16.2 on macOS 15.3.2)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featurescrashBug: A crash, i.e., an abnormal termination of software

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions