-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Description
I have several other recent bug reports about existentials (#70988, #71000, #71012, #71019). They all fail in unique cases. However, this one appears to crash from a different function in swift-frontend
, so it could be a different bug entirely.
- Different from Crash with existential any in function context #70988 because the workaround of returning type
Void
doesn't work here. - Different from Compiler crash with cast involving any existentials #71000 because this is unrelated to casting.
- Different from Compiler crash with generics involving existentials #71012 because that seems like a type-inference-related bug.
- Different from Compiler crash with optional existential #71019 as this issue isn't about optionals.
Reproduction
protocol A<T> {
associatedtype T
}
protocol B {}
typealias C = A & B
typealias D<T> = A<T> & B
struct Foo<Value>: C {
typealias T = Value
}
struct Bar<T> {}
@available(iOS 16, *)
struct Baz<T> {
init(fn: (any D<T>, Bar<T>) -> Void) {}
}
Stack dump
NOTE: This only appeared to crash within a package—moving the reproduction code to a separate file appeared to compile fine, so likely something I'm doing wrong on my part. Instances of <FILE>
and <PROJECT>
replace actual file name and package name respectfully. Log fetched from Xcode:
1. Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
2. Compiling with the current language version
3. While evaluating request IRGenRequest(IR Generation for file "<FILE>")
4. While emitting IR SIL function "@$s14<PROJECT>3BazV2fnACyxGyAA1A_AA1Bpx1TRts_XP_AA3BarVyxGtXE_tcfC".
for 'init(fn:)' (at <FILE>:173:5)
5. While mangling type for debugger type '@noescape @callee_guaranteed (@in_guaranteed A<T> & B, Bar<τ_0_0>) -> ()'
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 0x00000001032edabc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x0000000105f53cb0 llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x0000000105cbd054 SignalHandler(int) + 352
3 libsystem_platform.dylib 0x0000000187b5da24 _sigtramp + 56
4 swift-frontend 0x000000010371e3ec swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 140
5 swift-frontend 0x000000010371e3ec swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 140
6 swift-frontend 0x0000000103716378 swift::Mangle::ASTMangler::appendConstrainedExistential(swift::Type, swift::GenericSignature, swift::ValueDecl const*) + 624
7 swift-frontend 0x00000001037180a0 swift::Mangle::ASTMangler::appendImplFunctionType(swift::SILFunctionType*, swift::GenericSignature, swift::ValueDecl const*) + 1572
8 swift-frontend 0x000000010370e7d0 swift::Mangle::ASTMangler::mangleTypeForDebugger(swift::Type, swift::GenericSignature) + 496
9 swift-frontend 0x0000000102c29214 (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) + 1164
10 swift-frontend 0x000000010518ae44 (anonymous namespace)::IRGenDebugInfoImpl::emitVariableDeclaration(swift::irgen::IRBuilder&, llvm::ArrayRef<llvm::Value*>, swift::irgen::DebugTypeInfo, swift::SILDebugScope const*, llvm::Optional<swift::SILLocation>, swift::SILDebugVariable, swift::irgen::IndirectionKind, swift::irgen::ArtificialKind, swift::irgen::AddrDbgInstrKind) (.llvm.11273107327267601125) + 592
11 swift-frontend 0x0000000102bfe454 swift::irgen::IRGenDebugInfo::emitVariableDeclaration(swift::irgen::IRBuilder&, llvm::ArrayRef<llvm::Value*>, swift::irgen::DebugTypeInfo, swift::SILDebugScope const*, llvm::Optional<swift::SILLocation>, swift::SILDebugVariable, swift::irgen::IndirectionKind, swift::irgen::ArtificialKind, swift::irgen::AddrDbgInstrKind) + 276
12 swift-frontend 0x0000000102efd364 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 129848
13 swift-frontend 0x0000000105671fdc swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 11680
14 swift-frontend 0x00000001032709c8 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&) + 2516
15 swift-frontend 0x00000001019159d0 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 6532
16 swift-frontend 0x00000001011e8adc swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 176
17 swift-frontend 0x0000000102bb9f64 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 1480
18 swift-frontend 0x0000000104e60fb8 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**) + 264
19 swift-frontend 0x000000010582d99c 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
20 swift-frontend 0x00000001058356d4 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*) + 1596
21 swift-frontend 0x0000000105830a08 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1748
22 swift-frontend 0x0000000105834854 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
23 swift-frontend 0x000000010589bd44 swift::mainEntry(int, char const**) + 4408
24 dyld 0x00000001877ad0e0 start + 2360
Command SwiftCompile failed with a nonzero exit code
Expected behavior
The program should compile without the compiler crashing.
Environment
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
Additional information
Workaround
Removing either of the two function arguments stops the compiler crashing, but obviously changes behaviour.