Open swift-ci opened 3 years ago
Issue Description:
["v": Int?(1)] as [String: String?]
This code causes complier crash.
❯ swift test.swift test.swift:1:16: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead ["v": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ test.swift:1:16: warning: expression of type '[String : String?]' is unused ["v": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ PHI node operands are not the same type as the result! %36 = phi i64 [ 0, %33 ], [ %29, %31 ], !dbg !48 in function main <unknown>:0: error: fatal error encountered during compilation; please submit a bug report ([https://swift.org/contributing/#reporting-bugs]) and include the project <unknown>:0: note: Broken function found, compilation aborted! Please submit a bug report ([https://swift.org/contributing/#reporting-bugs]) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /Applications/Xcode_12.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret test.swift -enable-objc-interop -sdk /Applications/Xcode_12.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -color-diagnostics -target-sdk-version 11.3 -module-name test 1. Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55) 2. While running user code "test.swift" 3. Running pass 'Module Verifier' on function '@main' 0 swift-frontend 0x0000000113b04e85 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 1 swift-frontend 0x0000000113b03e78 llvm::sys::RunSignalHandlers() + 248 2 swift-frontend 0x0000000113b05446 SignalHandler(int) + 262 3 libsystem_platform.dylib 0x00007fff203dbd7d _sigtramp + 29 4 libsystem_platform.dylib 0x00007ffee0f78108 _sigtramp + 18446744072647984040 5 libsystem_c.dylib 0x00007fff202ea720 abort + 120 6 swift-frontend 0x000000010ed27a31 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_1::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 1169 7 swift-frontend 0x0000000113a5a2d0 llvm::report_fatal_error(llvm::Twine const&, bool) + 288 8 swift-frontend 0x0000000113a5a1ab llvm::report_fatal_error(char const*, bool) + 43 9 swift-frontend 0x00000001139fa37f (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) + 111 10 swift-frontend 0x00000001139940b9 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1353 11 swift-frontend 0x00000001139933a0 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 112 12 swift-frontend 0x000000011399a835 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 341 13 swift-frontend 0x000000010f0d33e8 swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*) + 1688 14 swift-frontend 0x000000010f0d4486 swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 2582 15 swift-frontend 0x000000010ed6938d swift::RunImmediately(swift::CompilerInstance&, 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&, swift::IRGenOptions const&, swift::SILOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >&&) + 461 16 swift-frontend 0x000000010ed33375 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*) + 2421 17 swift-frontend 0x000000010ed250ab swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7275 18 swift-frontend 0x000000010eca6e82 main + 1266 19 libdyld.dylib 0x00007fff203b2621 start + 1 20 libdyld.dylib 0x000000000000000c start + 18446603339975416300 [1] 5197 abort swift test.swift
It seems that swift5.2.5 can compile this but swift5.4, swift5.3.3 cannot compile this code.
Also, the next similer code causes compiler crash too. The error message seems different from the previous one.
["v": 1] as [String: String]
❯ swift test2.swift test2.swift:1:10: warning: coercion from '[String : Int]' to '[String : String]' may fail; use 'as?' or 'as!' instead ["v": 1] as [String: String] ~~~~~~~~~^~~~~~~~~~~~~~~~~~~ test2.swift:1:10: warning: expression of type '[String : String]' is unused ["v": 1] as [String: String] ~~~~~~~~~^~~~~~~~~~~~~~~~~~~ Please submit a bug report ([https://swift.org/contributing/#reporting-bugs]) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /Applications/Xcode_12.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret test2.swift -enable-objc-interop -sdk /Applications/Xcode_12.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -color-diagnostics -target-sdk-version 11.3 -module-name test2 1. Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55) 2. While running user code "test2.swift" 3. While evaluating request IRGenRequest(IR Generation for module test2) 4. While emitting IR SIL function "@main". 0 swift-frontend 0x000000010cec9e85 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 1 swift-frontend 0x000000010cec8e78 llvm::sys::RunSignalHandlers() + 248 2 swift-frontend 0x000000010ceca446 SignalHandler(int) + 262 3 libsystem_platform.dylib 0x00007fff203dbd7d _sigtramp + 29 4 libsystem_platform.dylib 0x00007f81fd627d40 _sigtramp + 18446743536253845472 5 swift-frontend 0x00000001084d1096 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 10198 6 swift-frontend 0x0000000108358dc7 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&) + 1623 7 swift-frontend 0x000000010849dd11 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 10801 8 swift-frontend 0x00000001084ce5ed swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 157 9 swift-frontend 0x00000001084a94dc llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 1404 10 swift-frontend 0x00000001084a0143 swift::performIRGeneration(swift::ModuleDecl*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::GlobalVariable**) + 1523 11 swift-frontend 0x000000010812e2ea swift::RunImmediately(swift::CompilerInstance&, 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&, swift::IRGenOptions const&, swift::SILOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >&&) + 298 12 swift-frontend 0x00000001080f8375 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*) + 2421 13 swift-frontend 0x00000001080ea0ab swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7275 14 swift-frontend 0x000000010806be82 main + 1266 15 libdyld.dylib 0x00007fff203b2621 start + 1 [1] 5409 segmentation fault swift test2.swift
@swift-ci create
Comment by Iceman (JIRA)
Also crashes on Swift 5.5.2
Environment
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55) Target: x86_64-apple-darwin20.3.0Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 78178fbc8295d81ec372090baee6e3e3Issue Description:
This code causes complier crash.
It seems that swift5.2.5 can compile this but swift5.4, swift5.3.3 cannot compile this code.
Also, the next similer code causes compiler crash too. The error message seems different from the previous one.