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

Assertion failed: (!factory.isOutsideBodyOfFunction(afd) && "Should be inside"), function lookInMembers

    XMLWordPrintable

    Details

      Description

      Compile the below to reproduce. Also crashes sourcekit.

       public final class Foo {
          public var a: String {
              return "\(backgroundContext)"

      It's a different assertion, but it seems like it might be related to https://bugs.swift.org/browse/SR-12997. (both have an interpolated string at the end of their source range, so I'm guessing this is due to the interpolation content being past the token-start-based parent end location).

      Trace:

      Assertion failed: (!factory.isOutsideBodyOfFunction(afd) && "Should be inside"), function lookInMembers, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/AST/UnqualifiedLookup.cpp, line 1261.
       
      
      Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
      0   libsystem_kernel.dylib        	0x00007fff6b42d33a __pthread_kill + 10
      1   libsystem_pthread.dylib       	0x00007fff6b4e9e60 pthread_kill + 430
      2   libsystem_c.dylib             	0x00007fff6b3b48a2 __abort + 139
      3   libsystem_c.dylib             	0x00007fff6b3b4817 abort + 135
      4   libsystem_c.dylib             	0x00007fff6b3b3ac6 __assert_rtn + 314
      5   swift                         	0x000000010483c7f3 (anonymous namespace)::ASTScopeDeclConsumerForUnqualifiedLookup::lookInMembers(swift::NullablePtr<swift::DeclContext>, swift::DeclContext*, swift::NominalTypeDecl*, llvm::function_ref<bool (llvm::Optional<bool>)>) (.cold.1) + 35
      6   swift                         	0x00000001012b434a (anonymous namespace)::ASTScopeDeclConsumerForUnqualifiedLookup::lookInMembers(swift::NullablePtr<swift::DeclContext>, swift::DeclContext*, swift::NominalTypeDecl*, llvm::function_ref<bool (llvm::Optional<bool>)>) + 122
      7   swift                         	0x00000001010f32aa swift::ast_scope::GenericTypeOrExtensionWhereOrBodyPortion::lookupMembersOf(swift::ast_scope::GenericTypeOrExtensionScope const*, llvm::ArrayRef<swift::ast_scope::ASTScopeImpl const*>, swift::namelookup::AbstractASTScopeDeclConsumer&) const + 122
      8   swift                         	0x00000001010f2c52 swift::ast_scope::ASTScopeImpl::lookup(llvm::SmallVectorImpl<swift::ast_scope::ASTScopeImpl const*>&, swift::NullablePtr<swift::ast_scope::ASTScopeImpl const>, swift::NullablePtr<swift::GenericParamList const>, swift::namelookup::AbstractASTScopeDeclConsumer&) const + 178
      9   swift                         	0x00000001010f2724 swift::ast_scope::ASTScopeImpl::unqualifiedLookup(swift::SourceFile*, swift::DeclNameRef, swift::SourceLoc, swift::DeclContext const*, swift::namelookup::AbstractASTScopeDeclConsumer&) + 68
      10  swift                         	0x00000001010dc8d6 swift::ASTScope::unqualifiedLookup(swift::SourceFile*, swift::DeclNameRef, swift::SourceLoc, swift::DeclContext const*, swift::namelookup::AbstractASTScopeDeclConsumer&) + 86
      11  swift                         	0x00000001012b334f (anonymous namespace)::UnqualifiedLookupFactory::lookInASTScopes() + 191
      12  swift                         	0x00000001012b1a64 swift::UnqualifiedLookupRequest::evaluate(swift::Evaluator&, swift::UnqualifiedLookupDescriptor) const + 932
      13  swift                         	0x00000001012683c3 swift::SimpleRequest<swift::UnqualifiedLookupRequest, swift::LookupResult (swift::UnqualifiedLookupDescriptor), (swift::RequestFlags)25>::evaluateRequest(swift::UnqualifiedLookupRequest const&, swift::Evaluator&) + 35
      14  swift                         	0x0000000101258762 llvm::Expected<swift::UnqualifiedLookupRequest::OutputType> swift::Evaluator::getResultUncached<swift::UnqualifiedLookupRequest>(swift::UnqualifiedLookupRequest const&) + 354
      15  swift                         	0x00000001012585a6 llvm::Expected<swift::UnqualifiedLookupRequest::OutputType> swift::Evaluator::operator()<swift::UnqualifiedLookupRequest, (void*)0>(swift::UnqualifiedLookupRequest const&) + 118
      16  swift                         	0x00000001012583a6 swift::UnqualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::UnqualifiedLookupRequest>(swift::Evaluator&, swift::UnqualifiedLookupRequest, swift::UnqualifiedLookupRequest::OutputType) + 38
      17  swift                         	0x0000000100e6baa9 swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclNameRef, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 185
      18  swift                         	0x0000000100e17445 swift::TypeChecker::resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*) + 117
      19  swift                         	0x0000000100e23df7 (anonymous namespace)::PreCheckExpression::walkToExprPre(swift::Expr*) + 1015
      20  swift                         	0x00000001010f7c6a swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 202
      21  swift                         	0x00000001010f9dcf (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 207
      22  swift                         	0x00000001010f9f7b swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 219
      23  swift                         	0x00000001010f93e4 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 6212
      24  swift                         	0x00000001010f8944 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 3492
      25  swift                         	0x00000001010f75f1 swift::Expr::walk(swift::ASTWalker&) + 81
      26  swift                         	0x0000000100e1a28c swift::constraints::ConstraintSystem::preCheckExpression(swift::Expr*&, swift::DeclContext*) + 188
      27  swift                         	0x0000000100e1a595 swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 197
      28  swift                         	0x0000000100e1a437 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 87
      29  swift                         	0x0000000100ebc923 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 5683
      30  swift                         	0x0000000100ebce80 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 128
      31  swift                         	0x0000000100ebbd30 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 2624
      32  swift                         	0x0000000100eb91c0 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 128
      33  swift                         	0x0000000100eb8671 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1089
      34  swift                         	0x0000000100ebfb16 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest>(swift::TypeCheckFunctionBodyRequest const&) + 598
      35  swift                         	0x0000000100ebf64c llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 316
      36  swift                         	0x0000000100ebf4b6 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 118
      37  swift                         	0x0000000100eb7ef5 swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 37
      38  swift                         	0x0000000100eb7ea0 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 64
      39  swift                         	0x0000000100eebd4e swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 382
      40  swift                         	0x0000000100eeca65 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 453
      41  swift                         	0x0000000100eec784 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 52
      42  swift                         	0x0000000100eec6f6 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 118
      43  swift                         	0x0000000100eebae0 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 32
      44  swift                         	0x000000010025c78a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 90
      45  swift                         	0x000000010025c67a swift::CompilerInstance::performSema() + 74
      46  swift                         	0x000000010017ee19 performCompile(swift::CompilerInstance&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 2329
      47  swift                         	0x000000010017d519 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3529
      48  swift                         	0x0000000100119ccd main + 861
      49  libdyld.dylib                 	0x00007fff6b2e5cc9 start + 1
      

       

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            nathawes Nathan Hawes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: