Skip to content

complete_loop.swift fails with non-source-order completion #84785

@hamishknight

Description

@hamishknight

Disabling -source-order-completion in complete_loop.swift causes the following crash for certain completion orderings:

invalid DC kind for finding equivalent DC (indexpath)
UNREACHABLE executed at /Users/hamish/src/swift-dev/swift/lib/IDETool/IDEInspectionInstance.cpp:154!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test -target arm64-apple-macosx13.0 -module-cache-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/swift-test-results/arm64-apple-macosx13.0/clang-module-cache -completion-cache-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/swift-test-results/arm64-apple-macosx13.0/completion-cache -swift-version 4 -batch-code-completion -source-filename /Users/hamish/src/swift-dev/swift/test/IDE/complete_loop.swift -filecheck /Users/hamish/src/swift-dev/build/Release/llvm-macosx-arm64/bin/FileCheck -completion-output-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/test-macosx-arm64/IDE/Output/complete_loop.swift.tmp/batch-code-completion
1.      While performing cached IDE inspection if possible
2.      While getting equivalent decl context for in decl context:
    ---
    0xc75773000 Module name=_
      0xc757736a0 FileUnit file="/Users/hamish/src/swift-dev/swift/test/IDE/complete_loop.swift"
        0xc75181e20 TopLevelCodeDecl line=85
          0xc75180310 AbstractFunctionDecl name=bar(_:) : (no type set)
    ---
 #0 0x00000001086690dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x105e750dc)
 #1 0x0000000108666df4 llvm::sys::RunSignalHandlers() (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x105e72df4)
 #2 0x0000000108669bc4 SignalHandler(int, __siginfo*, void*) (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x105e75bc4)
 #3 0x000000019486f744 (/usr/lib/system/libsystem_platform.dylib+0x1804e3744)
 #4 0x0000000194865888 (/usr/lib/system/libsystem_pthread.dylib+0x1804d9888)
 #5 0x000000019476a850 (/usr/lib/system/libsystem_c.dylib+0x1803de850)
 #6 0x00000001085df85c llvm::install_out_of_memory_new_handler() (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x105deb85c)
 #7 0x0000000102dafac0 (anonymous namespace)::getEquivalentDeclContextFromSourceFile(swift::DeclContext*, swift::SourceFile*) (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x1005bbac0)
 #8 0x0000000102daeeb0 swift::ide::IDEInspectionInstance::performCachedOperationIfPossible(llvm::hash_code, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, swift::SearchPathOptions const&, llvm::MemoryBuffer*, unsigned int, swift::DiagnosticConsumer*, std::__1::shared_ptr<std::__1::atomic<bool>>, llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::IDEInspectionInstanceResult>)>) (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x1005baeb0)
 #9 0x0000000102db084c swift::ide::IDEInspectionInstance::performOperation(swift::CompilerInvocation&, llvm::ArrayRef<char const*>, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, llvm::MemoryBuffer*, unsigned int, swift::DiagnosticConsumer*, std::__1::shared_ptr<std::__1::atomic<bool>>, llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::IDEInspectionInstanceResult>)>) (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x1005bc84c)
#10 0x0000000102db0b68 swift::ide::IDEInspectionInstance::codeComplete(swift::CompilerInvocation&, llvm::ArrayRef<char const*>, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, llvm::MemoryBuffer*, unsigned int, swift::DiagnosticConsumer*, swift::ide::CodeCompletionContext&, std::__1::shared_ptr<std::__1::atomic<bool>>, llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::CodeCompleteResult>)>) (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x1005bcb68)
#11 0x0000000102835b24 doBatchCodeCompletion(swift::CompilerInvocation const&, llvm::StringRef, bool, bool, bool, bool, bool, bool, bool, bool, bool) (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x100041b24)
#12 0x000000010283277c main (/Users/hamish/src/swift-dev/build/Release/swift-macosx-arm64/bin/swift-ide-test+0x10003e77c)

Minimal reproducer:

func 0 {
#^^#
}
do { func a {
#^b^#

Metadata

Metadata

Assignees

Labels

SourceKitArea → source tooling: SourceKitbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completioncrashBug: 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