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

Assertion failed: (hasInterfaceType() && "No interface type was set")

    XMLWordPrintable

    Details

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

      macOS 10.13.4, running Xcode 9.3 with default toolchain (works OK) and with toolchain Swift Development Snapshot 2018-04-23 (crashes).

      Description

      I was using XCUITest's record functionality to try creating some user interface testing. It didn't work (not uncommon), but this time it didn't work so hard that it also crashes the compiler. If I change the toolchain to the one that ships with Xcode 9.3 it compiles with errors (because the code is bad), but if I switch to a newer toolchain (2018-04-23) then I get "Command failed due to signal: Abort trap: 6."

      Assertion failed: (hasInterfaceType() && "No interface type was set"), function getInterfaceType, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/AST/Decl.cpp, line 1998.
      0  swift                    0x00000001079e2aa8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
      1  swift                    0x00000001079e31b6 SignalHandler(int) + 694
      2  libsystem_platform.dylib 0x00007fff5a88ef5a _sigtramp + 26
      3  libdyld.dylib            0x00007fff5a580149 dyldGlobalLockRelease() + 0
      4  libsystem_c.dylib        0x00007fff5a62c1ae abort + 127
      5  libsystem_c.dylib        0x00007fff5a5f41ac basename_r + 0
      6  swift                    0x0000000105407667 swift::VarDecl::getType() const + 279
      7  swift                    0x000000010506aeab swift::TypeChecker::getUnopenedTypeOfReference(swift::VarDecl*, swift::Type, swift::DeclContext*, swift::DeclRefExpr const*, bool) + 91
      8  swift                    0x000000010506b68f swift::constraints::ConstraintSystem::getTypeOfReference(swift::ValueDecl*, swift::FunctionRefKind, swift::constraints::ConstraintLocatorBuilder, swift::DeclRefExpr const*) + 383
      9  swift                    0x000000010506d8a7 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) + 615
      10 swift                    0x0000000105007445 swift::ASTVisitor<(anonymous namespace)::ConstraintGenerator, swift::Type, void, void, void, void, void>::visit(swift::Expr*) + 9461
      11 swift                    0x000000010500dd5f (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 415
      12 swift                    0x00000001053d48d6 swift::Expr::walk(swift::ASTWalker&) + 118
      13 swift                    0x0000000105003b59 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*) + 409
      14 swift                    0x000000010503a81a swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 474
      15 swift                    0x00000001050c8d64 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 52
      16 swift                    0x00000001050cc499 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 969
      17 swift                    0x00000001050d07f2 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, bool) + 434
      18 swift                    0x00000001050d0b0e swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 238
      19 swift                    0x00000001050eee60 validatePatternBindingEntries(swift::TypeChecker&, swift::PatternBindingDecl*) + 880
      20 swift                    0x00000001050e9cd5 swift::TypeChecker::validateDecl(swift::ValueDecl*) + 5285
      21 swift                    0x00000001050c87d2 findNonMembers(swift::TypeChecker&, llvm::ArrayRef<swift::LookupResultEntry>, swift::DeclRefKind, bool, llvm::SmallVectorImpl<swift::ValueDecl*>&, llvm::function_ref<bool (swift::ValueDecl*)>) + 194
      22 swift                    0x00000001050c6e55 swift::TypeChecker::resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*) + 853
      23 swift                    0x00000001050d56e6 (anonymous namespace)::PreCheckExpression::walkToExprPre(swift::Expr*) + 358
      24 swift                    0x00000001053d487e swift::Expr::walk(swift::ASTWalker&) + 30
      25 swift                    0x00000001050cc1e6 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 278
      26 swift                    0x00000001050d07f2 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, bool) + 434
      27 swift                    0x00000001050d0b0e swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 238
      28 swift                    0x00000001050eee60 validatePatternBindingEntries(swift::TypeChecker&, swift::PatternBindingDecl*) + 880
      29 swift                    0x00000001050e5be5 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 773
      30 swift                    0x00000001050e58d6 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
      31 swift                    0x000000010515c772 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 514
      32 swift                    0x000000010515b785 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 85
      33 swift                    0x000000010515ab08 swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 328
      34 swift                    0x000000010515b671 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 465
      35 swift                    0x000000010517fbc2 typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 354
      36 swift                    0x0000000105180ad8 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 1816
      37 swift                    0x0000000104db9048 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 744
      38 swift                    0x0000000104db8928 swift::CompilerInstance::performSema() + 472
      39 swift                    0x0000000104246180 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1904
      40 swift                    0x00000001042449fe swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3310
      41 swift                    0x000000010420131d main + 2317
      42 libdyld.dylib            0x00007fff5a580015 start + 1
      Stack dump:
      0.	Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-04-23-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/twostraws/Desktop/XCUITestSandbox-Modified/XCUITestSandboxUITests/XCUITestSandboxUITests.swift -emit-module-path /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/Objects-normal/x86_64/XCUITestSandboxUITests~partial.swiftmodule -emit-module-doc-path /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/Objects-normal/x86_64/XCUITestSandboxUITests~partial.swiftdoc -serialize-diagnostics-path /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/Objects-normal/x86_64/XCUITestSandboxUITests.dia -emit-dependencies-path /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/Objects-normal/x86_64/XCUITestSandboxUITests.d -emit-reference-dependencies-path /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/Objects-normal/x86_64/XCUITestSandboxUITests.swiftdeps -target x86_64-apple-ios11.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk -I /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Products/Debug-iphonesimulator -F /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Products/Debug-iphonesimulator -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/twostraws/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -serialize-debugging-options -Xcc -I/Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/XCUITestSandboxUITests-generated-files.hmap -Xcc -I/Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/XCUITestSandboxUITests-own-target-headers.hmap -Xcc -I/Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/XCUITestSandboxUITests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/XCUITestSandboxUITests-project-headers.hmap -Xcc -I/Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/DerivedSources/x86_64 -Xcc -I/Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/twostraws/Desktop/XCUITestSandbox-Modified -parse-as-library -module-name XCUITestSandboxUITests -o /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Build/Intermediates.noindex/XCUITestSandbox.build/Debug-iphonesimulator/XCUITestSandboxUITests.build/Objects-normal/x86_64/XCUITestSandboxUITests.o -index-store-path /Users/twostraws/Library/Developer/Xcode/DerivedData/XCUITestSandbox-bdhldtenibsxlnffnskdowgcirid/Index/DataStore -index-system-modules 
      1.	While type-checking 'testExample()' at /Users/twostraws/Desktop/XCUITestSandbox-Modified/XCUITestSandboxUITests/XCUITestSandboxUITests.swift:31:5
      2.	While type-checking statement at [/Users/twostraws/Desktop/XCUITestSandbox-Modified/XCUITestSandboxUITests/XCUITestSandboxUITests.swift:31:24 - line:58:5] RangeText="{
      
              let app = app2
              app.otherElements.containing(.navigationBar, identifier:"Alpha").children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .textField).element.tap()
      
              let tKey = app/*@START_MENU_TOKEN@*/.keys["t"]/*[[".keyboards.keys[\"t\"]",".keys[\"t\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
              tKey.tap()
              tKey.tap()
      
              let eKey = app/*@START_MENU_TOKEN@*/.keys["e"]/*[[".keyboards.keys[\"e\"]",".keys[\"e\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
              eKey.tap()
              eKey.tap()
      
              let sKey = app/*@START_MENU_TOKEN@*/.keys["s"]/*[[".keyboards.keys[\"s\"]",".keys[\"s\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
              sKey.tap()
              sKey.tap()
              tKey.tap()
              tKey.tap()
      
              let app2 = app
              app2/*@START_MENU_TOKEN@*/.buttons["Return"]/*[[".keyboards",".buttons[\"return\"]",".buttons[\"Return\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/.tap()
              app.sliders["50%"].swipeRight()
              app2/*@START_MENU_TOKEN@*/.buttons["Omega"]/*[[".segmentedControls.buttons[\"Omega\"]",".buttons[\"Omega\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
              app.buttons["Blue"].tap()
      
              // Use recording to get started writing UI tests.
              // Use XCTAssert and related functions to verify your tests produce the correct results.
          }"
      3.	While type-checking declaration 0x7f899a875880 at /Users/twostraws/Desktop/XCUITestSandbox-Modified/XCUITestSandboxUITests/XCUITestSandboxUITests.swift:33:9
      4.	While type-checking expression at [/Users/twostraws/Desktop/XCUITestSandbox-Modified/XCUITestSandboxUITests/XCUITestSandboxUITests.swift:33:19 - line:33:19] RangeText="a"
      5.	While validating 'app2' at /Users/twostraws/Desktop/XCUITestSandbox-Modified/XCUITestSandboxUITests/XCUITestSandboxUITests.swift:50:13
      6.	While type-checking expression at [/Users/twostraws/Desktop/XCUITestSandbox-Modified/XCUITestSandboxUITests/XCUITestSandboxUITests.swift:50:20 - line:50:20] RangeText="a"
      

      I have attached the test Swift code that was generated by Xcode. To be clear, I'm not suggesting this code compile cleanly – it was auto-generated by Xcode, and is clearly broken in places. However, it should not break the compiler, particularly when it did not previously.

      Note: in case you're not familiar with XCUITest, it uses magic comments to present UI inside Xcode – that's all the /@START_MENU_TOKEN@/ stuff.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              twostraws Paul Hudson
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: