Uploaded image for project: 'Swift'
  1. Swift
  2. SR-12460

Declaring an operator inside an extension without a name crashes the compiler

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:

      Description

      Trying to compile the following code crashes the compiler:

      extension {
        func ==(lhs: Foo, rhs: Foo) -> Bool {}
      } 

      Note that the extension hasn’t got a name.

       

      Stack trace:

      1.	Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
      2.	While evaluating request IsStaticRequest(test.(file). extension.==@/Users/alex/Desktop/test/test/main.swift:2:8)
      0  swift                    0x000000010482a4ea PrintStackTraceSignalHandler(void*) + 42
      1  swift                    0x0000000104829cc0 SignalHandler(int) + 352
      2  libsystem_platform.dylib 0x00007fff6bdc042d _sigtramp + 29
      3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2485386224
      4  swift                    0x00000001015d9671 swift::DiagnosticEngine::formatDiagnosticText(llvm::raw_ostream&, llvm::StringRef, llvm::ArrayRef<swift::DiagnosticArgument>, swift::DiagnosticFormatOptions) + 5633
      5  swift                    0x0000000100899d7b swift::PrintingDiagnosticConsumer::printDiagnostic(swift::SourceManager&, swift::DiagnosticInfo const&) + 1291
      6  swift                    0x00000001008995fd swift::PrintingDiagnosticConsumer::handleDiagnostic(swift::SourceManager&, swift::DiagnosticInfo const&) + 45
      7  swift                    0x00000001015d65e1 swift::DiagnosticEngine::emitDiagnostic(swift::Diagnostic const&) + 1713
      8  swift                    0x00000001015d5c9c swift::DiagnosticEngine::flushActiveDiagnostic() + 604
      9  swift                    0x000000010122349d swift::SimpleRequest<swift::IsStaticRequest, bool (swift::FuncDecl*), (swift::CacheKind)2>::evaluateRequest(swift::IsStaticRequest const&, swift::Evaluator&) + 1805
      10 swift                    0x000000010157f99e swift::IsStaticRequest::OutputType swift::evaluateOrDefault<swift::IsStaticRequest>(swift::Evaluator&, swift::IsStaticRequest, swift::IsStaticRequest::OutputType) + 958
      11 swift                    0x00000001015991d2 swift::ValueDecl::isInstanceMember() const + 178
      12 swift                    0x000000010091570a swift::index::getSymbolInfoForDecl(swift::Decl const*) + 218
      13 swift                    0x000000010090a5dc (anonymous namespace)::IndexSwiftASTWalker::initIndexSymbol(swift::ValueDecl*, swift::SourceLoc, bool, swift::index::IndexSymbol&) + 252
      14 swift                    0x0000000100907357 (anonymous namespace)::IndexSwiftASTWalker::walkToDeclPre(swift::Decl*, swift::CharSourceRange) + 1911
      15 swift                    0x00000001008ff704 (anonymous namespace)::SemaAnnotator::walkToDeclPre(swift::Decl*) + 1876
      16 swift                    0x0000000101556dd6 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 230
      17 swift                    0x000000010155956e swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 2654
      18 swift                    0x0000000101556e03 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 275
      19 swift                    0x00000001016491b2 swift::SourceFile::walk(swift::ASTWalker&) + 146
      20 swift                    0x00000001008fdd0b swift::SourceEntityWalker::walk(swift::SourceFile&) + 235
      21 swift                    0x000000010090d5cf (anonymous namespace)::IndexSwiftASTWalker::visitModule(swift::ModuleDecl&) + 223
      22 swift                    0x000000010090ed96 recordSourceFileUnit(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, llvm::ArrayRef<clang::FileEntry const*>, clang::CompilerInstance const&, swift::DiagnosticEngine&) + 2870
      23 swift                    0x0000000100581e5b emitIndexDataIfNeeded(swift::SourceFile*, swift::CompilerInvocation const&, swift::CompilerInstance&) + 779
      24 swift                    0x000000010057a02a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 38282
      25 swift                    0x00000001004f44d3 main + 1283
      26 libdyld.dylib            0x00007fff6bbc77fd start + 1
      error: Segmentation fault: 11 (in target 'test' from project 'test') 

      Using Swift 5.2 shipped with Xcode 11.4 (11E146, swiftlang-1103.0.32.1)

        Attachments

          Activity

            People

            Assignee:
            eyork Eric York
            Reporter:
            ahoppen Alex Hoppen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: