Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
norio-nomura opened this issue Nov 10, 2016 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software SILGen Area → compiler: The SIL generation stage

Comments

@norio-nomura
Copy link
Contributor

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)
@belkadan
Copy link
Contributor

TYPE MISMATCH IN ARGUMENT 1 OF APPLY AT expression at [<stdin>:26:27 - line:26:27] RangeText="""
argument value:   %8 = metatype $@thin Test.Type, loc "<stdin>":26:27, scope 0
parameter type: @thick Test.Type

Possibly a SILGen issue, possibly a type-checker issue. Line 26 is the one with the static variable, but taking that out and writing "test" as Test at the top level also triggers the bug.

@slavapestov
Copy link
Member

#6543

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software SILGen Area → compiler: The SIL generation stage
Projects
None yet
Development

No branches or pull requests

4 participants