Skip to content

[SR-10725] Result type overload with two opaque result type cause compiler crash #53122

@omochi

Description

@omochi
Previous ID SR-10725
Radar rdar://problem/50987172
Original Reporter @omochi
Type Bug
Environment

swift-DEVELOPMENT-SNAPSHOT-2019-05-15-a

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, OpaqueResultTypes
Assignee None
Priority Medium

md5: 3388c921db937a08e8e1db54a7522585

Issue Description:

code

protocol P1 {}
extension Int : P1 {}
protocol P2 {}
extension Int : P2 {}
func f() -> some P1 { return 1 }
func f() -> some P2 { return 2 }

crash

Assertion failed: (fn->getLoweredFunctionType() == constantType), function getOrCreateFunction, file /Users/omochi/work/swift-source/swift/lib/SIL/SILFunctionBuilder.cpp, line 112.
Stack dump:
0.  Program arguments: /Users/omochi/work/swift-source/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/bin/swift -frontend -interpret a.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name a 
1.  Swift version 5.1-dev (LLVM 082dec2e22, Swift 60ee9527bb)
2.  While emitting SIL for 'f()' (at a.swift:7:1)
0  swift                    0x000000010da3618c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  swift                    0x000000010da366e9 PrintStackTraceSignalHandler(void*) + 25
2  swift                    0x000000010da33b36 llvm::sys::RunSignalHandlers() + 118
3  swift                    0x000000010da3c7c2 SignalHandler(int) + 210
4  libsystem_platform.dylib 0x00007fff66b07b5d _sigtramp + 29
5  libsystem_platform.dylib 0x000000000002da50 _sigtramp + 2572312336
6  libsystem_c.dylib        0x00007fff669c76a6 abort + 127
7  libsystem_c.dylib        0x00007fff6699020d basename_r + 0
8  swift                    0x0000000105c21f2c swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter) + 492
9  swift                    0x0000000105130eca swift::SILFunction* swift::Lowering::SILGenFunctionBuilder::getOrCreateFunction<swift::Decl*, swift::SILDeclRef&, swift::ForDefinition_t&>(swift::Decl*&&, swift::SILDeclRef&, swift::ForDefinition_t&) + 170
10 swift                    0x00000001051308b3 swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 275
11 swift                    0x0000000105132f42 void emitOrDelayFunction<swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_0>(swift::Lowering::SILGenModule&, swift::SILDeclRef, swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_0&&, bool) + 482
12 swift                    0x0000000105131a3e swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 734
13 swift                    0x000000010513174d swift::Lowering::SILGenModule::visitFuncDecl(swift::FuncDecl*) + 29
14 swift                    0x000000010513ac02 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 1170
15 swift                    0x000000010513a44e swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 622
16 swift                    0x000000010513b3c7 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 887
17 swift                    0x000000010513bbf6 swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&) + 38
18 swift                    0x00000001048fcb95 generateSILModules(swift::CompilerInvocation&, swift::CompilerInstance&) + 453
19 swift                    0x00000001048f3552 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1554
20 swift                    0x00000001048f2145 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2421
21 swift                    0x00000001047f3972 run_driver(llvm::StringRef, llvm::ArrayRef<char const*>) + 914
22 swift                    0x00000001047f238b main + 2731
23 libdyld.dylib            0x00007fff669223d5 start + 1
Abort trap: 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareopaque typesFeature → types: opaque typesoverloadingFeature: Overloading symbol namesswift 5.1type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions