Skip to content

[SR-3173] Conforming ExpressibleByStringLiteral by protocol extension crashes compiler #45761

Closed
@norio-nomura

Description

@norio-nomura
Previous ID SR-3173
Radar None
Original Reporter @norio-nomura
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee @slavapestov
Priority Medium

md5: 843c7963a83ba714175c22b93b7fbe7e

Issue Description:

➜  20:03:23  echo 'protocol P: Equatable, ExpressibleByStringLiteral {
    var uid: String { get }
    init(uid: String)
}

extension P {
    // Equatable
    public static func ==(lhs: Self, rhs: Self) -> Bool {
        return lhs.uid == rhs.uid
    }

    // ExpressibleByStringLiteral
    public init(stringLiteral value: String) {
        self.init(uid: value)
    }
    public init(unicodeScalarLiteral value: String) {
        self.init(uid: value)
    }
    public init(extendedGraphemeClusterLiteral value: String) {
        self.init(uid: value)
    }
}

struct Test: P {
    var uid: String
    static let s1: Test = "s1"
}

Test.s1 == "test"
'|swiftc -
<stdin>:29:9: warning: result of operator '==' is unused
Test.s1 == "test"
~~~~~~~ ^  ~~~~~~
0  swift                    0x00000001090bda3d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x00000001090bd466 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fff96fe7bba _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000004 _sigtramp + 1761707108
4  swift                    0x00000001064a2abe swift::irgen::CallEmission::emitToExplosion(swift::irgen::Explosion&) + 302
5  swift                    0x00000001065d007a (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 3018
6  swift                    0x00000001065bab28 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9336
7  swift                    0x00000001064dc231 swift::irgen::IRGenerator::emitGlobalTopLevel() + 1329
8  swift                    0x00000001065a034b performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1259
9  swift                    0x000000010646bc19 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23705
10 swift                    0x0000000106463f70 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17856
11 swift                    0x000000010642093e main + 8302
12 libdyld.dylib            0x00007fff96dda255 start + 1
13 libdyld.dylib            0x000000000000000f start + 1763859899
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file - -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name main -o /var/folders/kt/2mwy9b_56_7993x190pl_1fh0000gn/T/--aeb086.o 
1.  While emitting IR SIL function @main<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)

Metadata

Metadata

Assignees

Labels

SILGenArea → compiler: The SIL generation stagebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: 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