Open KaQuMiQ opened 2 years ago
Describe the bug
Compiler is crashing on assignment of async throwing function to a property through a method using a KeyPath.
Steps To Reproduce
Here is smallest code sample I could get:
struct Example { var crashing: () async throws -> Void mutating func assign<V>( _ keyPath: WritableKeyPath<Self, V>, _ value: V ) { self[keyPath: keyPath] = value } }
Code calling assign causes crash:
assign
var example: Example = .init {} example.assign( \.crashing, { print("compiler crash") } )
However, there is a workaround - explicitly marking closure as async throwing makes it compile without a crash.
example.assign( \.crashing, { () async throws in print("compiler crash") } )
There is no issue if the function is only async or only throwing.
Expected behavior
Compiler should not crash.
Environment (please fill out the following information)
Additional context
Previous Xcode (13.4) with swift 5.6 was not crashing on this.
Here is stack trace from Xcode 14.0:
1. Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50) 2. Compiling with the current language version 3. While evaluating request IRGenRequest(IR Generation for file "Example.swift") 4. While emitting IR SIL function "@$sytIegHr_yts5Error_pIegHrzo_TR". for <<debugloc at "<compiler-generated>":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 0x000000010524fe70 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 swift-frontend 0x000000010524ee74 llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x00000001052504f4 SignalHandler(int) + 344 3 libsystem_platform.dylib 0x00000001aad234a4 _sigtramp + 56 4 libsystem_pthread.dylib 0x00000001aad0bee0 pthread_kill + 288 5 libsystem_c.dylib 0x00000001aac46340 abort + 168 6 swift-frontend 0x00000001008aa524 PrettyStackTraceFrontend::~PrettyStackTraceFrontend() + 0 7 swift-frontend 0x00000001051aed88 llvm::report_fatal_error(llvm::Twine const&, bool) + 280 8 swift-frontend 0x00000001051fb080 report_at_maximum_capacity(unsigned long) + 0 9 swift-frontend 0x00000001051faed4 llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) + 228 10 swift-frontend 0x0000000100b240c0 (anonymous namespace)::AsyncCallEmission::setArgs(swift::irgen::Explosion&, bool, swift::irgen::WitnessMetadata*) + 468 11 swift-frontend 0x0000000100cc62b0 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 4032 12 swift-frontend 0x0000000100ca58e8 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 7860 13 swift-frontend 0x0000000100b73364 swift::irgen::IRGenerator::emitLazyDefinitions() + 1156 14 swift-frontend 0x0000000100c73924 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 3024 15 swift-frontend 0x0000000100ca3768 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 188 16 swift-frontend 0x0000000100c7fc44 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 744 17 swift-frontend 0x0000000100c76b38 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**) + 236 18 swift-frontend 0x00000001008a13cc 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*) + 2160 19 swift-frontend 0x00000001008a3158 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5932 20 swift-frontend 0x0000000100843c44 swift::mainEntry(int, char const**) + 3940 21 dyld 0x0000000107cbd08c start + 520
This could very well be a duplicate of #61349. It produces the exact same stack trace on the main branch.
main
Describe the bug
Compiler is crashing on assignment of async throwing function to a property through a method using a KeyPath.
Steps To Reproduce
Here is smallest code sample I could get:
Code calling
assign
causes crash:However, there is a workaround - explicitly marking closure as async throwing makes it compile without a crash.
There is no issue if the function is only async or only throwing.
Expected behavior
Compiler should not crash.
Environment (please fill out the following information)
Additional context
Previous Xcode (13.4) with swift 5.6 was not crashing on this.
Here is stack trace from Xcode 14.0: