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-14916] Assertion failed: (knownBinding != typeBindings.end()) in solver-based key path completion #57263

Closed
ahoppen opened this issue Jul 13, 2021 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Jul 13, 2021

Previous ID SR-14916
Radar rdar://80522345
Original Reporter @ahoppen
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug, FoundByStressTester
Assignee @ahoppen
Priority Medium

md5: b66a6833f5e24d94cb315bc77bcc3761

Issue Description:

The following test case hits an assertion failure:

// RUN: %swift-ide-test -code-completion -code-completion-token COMPLETE -source-filename %s

protocol View2 {}
struct EmptyView: View2 {}

@resultBuilder public struct ViewBuilder2 {
  public static func buildBlock(_ content: EmptyView) -> EmptyView { fatalError() }
}

public struct List2 {
    public init(selection: Int?, @ViewBuilder2 content: () -> EmptyView)
    public init(selection: String?, @ViewBuilder2 content: () -> EmptyView)
}

func foo(kp: (Int) -> String) {}

func foo() {
    List2 {
        foo(kp: \.self#^COMPLETE^#)
    }
    .unknownMethod()
}

Stack trace

Assertion failed: (knownBinding != typeBindings.end()), function getFixedType, file /Users/alex/swift-src/swift/lib/Sema/CSApply.cpp, line 59.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /Users/alex/swift-src/nbuild/Release+Asserts/bin/swift-ide-test -module-cache-path /Users/alex/swift-src/nbuild/Release+Asserts/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -completion-cache-path /Users/alex/swift-src/nbuild/Release+Asserts/swift-test-results/x86_64-apple-macosx10.9/completion-cache -swift-version 4 -code-completion -code-completion-token COMPLETE -source-filename /Users/alex/swift-src/swift/test/SourceKit/test.swift
1.  While performing new completion
2.  While evaluating request CodeCompletionSecondPassRequest(source_file "/Users/alex/swift-src/swift/test/SourceKit/test.swift", )
3.  While evaluating request TypeCheckASTNodeAtLocRequest(0x7fbe9b040c18 AbstractFunctionDecl name=foo() : () -> (), )
4.  While evaluating request TypeCheckASTNodeAtLocRequest(0x7fbe9b040c18 AbstractFunctionDecl name=foo() : () -> (), )
5.  While type-checking expression at [/Users/alex/swift-src/swift/test/SourceKit/test.swift:18:5 - line:21:20] RangeText="List2 {
        foo(kp: \.self)
    }
    .unknownMethod("
6.  While code-completion expression at [/Users/alex/swift-src/swift/test/SourceKit/test.swift:18:5 - line:21:20] RangeText="List2 {
        foo(kp: \.self)
    }
    .unknownMethod("
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-ide-test           0x000000010612b2a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-ide-test           0x000000010612a1a8 llvm::sys::RunSignalHandlers() + 248
2  swift-ide-test           0x000000010612b8d6 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff20431d7d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603339974894240
5  libsystem_c.dylib        0x00007fff20341411 abort + 120
6  libsystem_c.dylib        0x00007fff203407e8 err + 0
7  swift-ide-test           0x00000001065d2981 swift::constraints::Solution::getFixedType(swift::TypeVariableType*) const (.cold.1) + 33
8  swift-ide-test           0x000000010240a4e5 swift::constraints::Solution::getFixedType(swift::TypeVariableType*) const + 181
9  swift-ide-test           0x000000010253bb14 swift::Type llvm::function_ref<swift::Type (swift::Type)>::callback_fn<swift::constraints::ConstraintSystem::simplifyTypeImpl(swift::Type, llvm::function_ref<swift::Type (swift::TypeVariableType*)>) const::$_21>(long, swift::Type) + 68
10 swift-ide-test           0x000000010197a6e2 llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const::$_20>(long, swift::TypeBase*) + 18
11 swift-ide-test           0x00000001019664b6 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 86
12 swift-ide-test           0x0000000101966b10 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 1712
13 swift-ide-test           0x0000000101954238 swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 40
14 swift-ide-test           0x000000010252a358 swift::constraints::Solution::simplifyType(swift::Type) const + 88
15 swift-ide-test           0x00000001025d8269 swift::KeyPathTypeCheckCompletionCallback::sawSolution(swift::constraints::Solution const&) + 153
16 swift-ide-test           0x00000001025d6a49 swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SolutionApplicationTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>)::$_2::operator()(swift::constraints::SolutionApplicationTarget&) const + 1513
17 swift-ide-test           0x00000001025d6316 swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SolutionApplicationTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>) + 838
18 swift-ide-test           0x00000001025eafc1 swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 305
19 swift-ide-test           0x00000001025eae0e swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 78
20 swift-ide-test           0x00000001026b1ed4 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 244
21 swift-ide-test           0x00000001026b22be swift::TypeCheckASTNodeAtLocRequest::evaluate(swift::Evaluator&, swift::DeclContext*, swift::SourceLoc) const + 542
22 swift-ide-test           0x00000001026efea3 llvm::Expected<swift::TypeCheckASTNodeAtLocRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckASTNodeAtLocRequest>(swift::TypeCheckASTNodeAtLocRequest const&) + 243
23 swift-ide-test           0x00000001026e9ce7 swift::TypeCheckASTNodeAtLocRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckASTNodeAtLocRequest>(swift::Evaluator&, swift::TypeCheckASTNodeAtLocRequest, swift::TypeCheckASTNodeAtLocRequest::OutputType) + 55
24 swift-ide-test           0x00000001026e9c91 swift::typeCheckASTNodeAtLoc(swift::DeclContext*, swift::SourceLoc) + 65
25 swift-ide-test           0x00000001026b227e swift::TypeCheckASTNodeAtLocRequest::evaluate(swift::Evaluator&, swift::DeclContext*, swift::SourceLoc) const + 478
26 swift-ide-test           0x00000001026efea3 llvm::Expected<swift::TypeCheckASTNodeAtLocRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckASTNodeAtLocRequest>(swift::TypeCheckASTNodeAtLocRequest const&) + 243
27 swift-ide-test           0x00000001026e9ce7 swift::TypeCheckASTNodeAtLocRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckASTNodeAtLocRequest>(swift::Evaluator&, swift::TypeCheckASTNodeAtLocRequest, swift::TypeCheckASTNodeAtLocRequest::OutputType) + 55
28 swift-ide-test           0x00000001026e9c91 swift::typeCheckASTNodeAtLoc(swift::DeclContext*, swift::SourceLoc) + 65
29 swift-ide-test           0x0000000101a52b03 swift::ide::typeCheckContextAt(swift::DeclContext*, swift::SourceLoc) + 771
30 swift-ide-test           0x0000000101a2b336 (anonymous namespace)::CodeCompletionCallbacksImpl::doneParsing() + 854
31 swift-ide-test           0x000000010295f998 swift::Parser::performCodeCompletionSecondPassImpl(swift::CodeCompletionDelayedDeclState&) + 888
32 swift-ide-test           0x000000010295f518 swift::CodeCompletionSecondPassRequest::evaluate(swift::Evaluator&, swift::SourceFile*, swift::CodeCompletionCallbacksFactory*) const + 232
33 swift-ide-test           0x0000000102969caf llvm::Expected<swift::CodeCompletionSecondPassRequest::OutputType> swift::Evaluator::getResultUncached<swift::CodeCompletionSecondPassRequest>(swift::CodeCompletionSecondPassRequest const&) + 271
34 swift-ide-test           0x000000010295f327 swift::CodeCompletionSecondPassRequest::OutputType swift::evaluateOrDefault<swift::CodeCompletionSecondPassRequest>(swift::Evaluator&, swift::CodeCompletionSecondPassRequest, swift::CodeCompletionSecondPassRequest::OutputType) + 55
35 swift-ide-test           0x0000000101a50ca1 swift::ide::CompletionInstance::performNewOperation(llvm::Optional<llvm::hash_code>, swift::CompilerInvocation&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, llvm::MemoryBuffer*, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, swift::DiagnosticConsumer*, llvm::function_ref<void (swift::CompilerInstance&, bool)>) + 529
36 swift-ide-test           0x0000000101a51138 swift::ide::CompletionInstance::performOperation(swift::CompilerInvocation&, llvm::ArrayRef<char const*>, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, llvm::MemoryBuffer*, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, swift::DiagnosticConsumer*, llvm::function_ref<void (swift::CompilerInstance&, bool)>) + 680
37 swift-ide-test           0x0000000101648420 doCodeCompletionImpl(swift::CodeCompletionCallbacksFactory*, swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool) + 1376
38 swift-ide-test           0x000000010163acd0 main + 26224
39 libdyld.dylib            0x00007fff20407f5d start + 1
40 libdyld.dylib            0x000000000000000c start + 18446603339975065776
@ahoppen
Copy link
Contributor Author

ahoppen commented Jul 21, 2021

Fixed in #38389

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
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. code completion Area → source tooling: code completion found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

2 participants