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-13877] Code Completion: Assertion failed: (!elt.getPattern()->hasType() && "the pattern binding condition is already type checked") #56275

Closed
nathawes opened this issue Nov 19, 2020 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@nathawes
Copy link
Collaborator

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

md5: 372bbc8a2102b525b524a82317e4e40f

Issue Description:

Reproducer on main:

$ cat /tmp/test.swift
if let item = ["a"].first(where: { #^COMPLETE^# }) {}

$ swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename /tmp/test.swift
found code completion token COMPLETE at offset 35
found code completion token COMPLETE at offset 35
Assertion failed: (!elt.getPattern()->hasType() && "the pattern binding condition is already type checked"), function typeCheckConditionForStatement, file swift/lib/Sema/TypeCheckStmt.cpp, line 516.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.  Program arguments: ../build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename /tmp/test.swift 
1.  While performing new completion
2.  While evaluating request CodeCompletionSecondPassRequest(source_file "/tmp/test.swift", )
3.  While evaluating request TypeCheckASTNodeAtLocRequest(0x7fd95306da60 TopLevelCodeDecl line=1, )
4.  While type-checking statement at [/tmp/test.swift:1:1 - line:1:39] RangeText="if let item = ["a"].first(where: {  }"
0  swift-ide-test           0x00000001112114fa llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 58
1  swift-ide-test           0x0000000111211a49 PrintStackTraceSignalHandler(void*) + 25
2  swift-ide-test           0x000000011120f9bb llvm::sys::RunSignalHandlers() + 123
3  swift-ide-test           0x00000001112137f9 SignalHandler(int) + 249
4  libsystem_platform.dylib 0x00007fff20369d7d _sigtramp + 29
5  libsystem_platform.dylib 0x000000000003c388 _sigtramp + 18446603339975960104
6  libsystem_c.dylib        0x00007fff20278720 abort + 120
7  libsystem_c.dylib        0x00007fff202779d6 err + 0
8  swift-ide-test           0x0000000108e7b931 typeCheckConditionForStatement(swift::LabeledConditionalStmt*, swift::DeclContext*) + 961
9  swift-ide-test           0x0000000108e797f8 (anonymous namespace)::StmtChecker::visitIfStmt(swift::IfStmt*) + 40
10 swift-ide-test           0x0000000108e78209 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 201
11 swift-ide-test           0x0000000108e77f21 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 161
12 swift-ide-test           0x0000000108e7156f (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 847
13 swift-ide-test           0x0000000108e711e8 swift::TypeChecker::typeCheckASTNode(swift::ASTNode&, swift::DeclContext*, bool) + 56
14 swift-ide-test           0x0000000108e7199c swift::TypeCheckASTNodeAtLocRequest::evaluate(swift::Evaluator&, swift::DeclContext*, swift::SourceLoc) const + 940
15 swift-ide-test           0x0000000108e67b41 bool swift::SimpleRequest<swift::TypeCheckASTNodeAtLocRequest, bool (swift::DeclContext*, swift::SourceLoc), (swift::RequestFlags)1>::callDerived<0ul, 1ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) const + 97
16 swift-ide-test           0x0000000108e63ea0 swift::SimpleRequest<swift::TypeCheckASTNodeAtLocRequest, bool (swift::DeclContext*, swift::SourceLoc), (swift::RequestFlags)1>::evaluateRequest(swift::TypeCheckASTNodeAtLocRequest const&, swift::Evaluator&) + 32
17 swift-ide-test           0x0000000108f1a806 llvm::Expected<swift::TypeCheckASTNodeAtLocRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckASTNodeAtLocRequest>(swift::TypeCheckASTNodeAtLocRequest const&) + 406
18 swift-ide-test           0x0000000108f1a5d0 llvm::Expected<swift::TypeCheckASTNodeAtLocRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckASTNodeAtLocRequest, (void*)0>(swift::TypeCheckASTNodeAtLocRequest const&) + 96
19 swift-ide-test           0x0000000108efebf9 swift::TypeCheckASTNodeAtLocRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckASTNodeAtLocRequest>(swift::Evaluator&, swift::TypeCheckASTNodeAtLocRequest, swift::TypeCheckASTNodeAtLocRequest::OutputType) + 57
20 swift-ide-test           0x0000000108efeba3 swift::typeCheckASTNodeAtLoc(swift::DeclContext*, swift::SourceLoc) + 99
21 swift-ide-test           0x0000000106ef94cc swift::ide::collectPossibleReturnTypesFromContext(swift::DeclContext*, llvm::SmallVectorImpl<swift::Type>&) + 364
22 swift-ide-test           0x0000000106efeb26 (anonymous namespace)::ExprContextAnalyzer::analyzeExpr(swift::Expr*) + 3126
23 swift-ide-test           0x0000000106ef9d7b (anonymous namespace)::ExprContextAnalyzer::Analyze() + 443
24 swift-ide-test           0x0000000106ef9b22 swift::ide::ExprContextInfo::ExprContextInfo(swift::DeclContext*, swift::Expr*) + 226
25 swift-ide-test           0x0000000106ef9a35 swift::ide::ExprContextInfo::ExprContextInfo(swift::DeclContext*, swift::Expr*) + 37
26 swift-ide-test           0x0000000106e9a6a5 (anonymous namespace)::CodeCompletionCallbacksImpl::doneParsing() + 3093
27 swift-ide-test           0x00000001094936ab swift::Parser::performCodeCompletionSecondPassImpl(swift::CodeCompletionDelayedDeclState&) + 1323
28 swift-ide-test           0x0000000109492e48 swift::CodeCompletionSecondPassRequest::evaluate(swift::Evaluator&, swift::SourceFile*, swift::CodeCompletionCallbacksFactory*) const + 376
29 swift-ide-test           0x00000001094cd079 bool swift::SimpleRequest<swift::CodeCompletionSecondPassRequest, bool (swift::SourceFile*, swift::CodeCompletionCallbacksFactory*), (swift::RequestFlags)9>::callDerived<0ul, 1ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) const + 89
30 swift-ide-test           0x00000001094ccf60 swift::SimpleRequest<swift::CodeCompletionSecondPassRequest, bool (swift::SourceFile*, swift::CodeCompletionCallbacksFactory*), (swift::RequestFlags)9>::evaluateRequest(swift::CodeCompletionSecondPassRequest const&, swift::Evaluator&) + 32
31 swift-ide-test           0x00000001094af6d6 llvm::Expected<swift::CodeCompletionSecondPassRequest::OutputType> swift::Evaluator::getResultUncached<swift::CodeCompletionSecondPassRequest>(swift::CodeCompletionSecondPassRequest const&) + 406
32 swift-ide-test           0x00000001094af480 llvm::Expected<swift::CodeCompletionSecondPassRequest::OutputType> swift::Evaluator::operator()<swift::CodeCompletionSecondPassRequest, (void*)0>(swift::CodeCompletionSecondPassRequest const&) + 96
33 swift-ide-test           0x0000000109492bc9 swift::CodeCompletionSecondPassRequest::OutputType swift::evaluateOrDefault<swift::CodeCompletionSecondPassRequest>(swift::Evaluator&, swift::CodeCompletionSecondPassRequest, swift::CodeCompletionSecondPassRequest::OutputType) + 57
34 swift-ide-test           0x0000000109492b80 swift::performCodeCompletionSecondPass(swift::SourceFile&, swift::CodeCompletionCallbacksFactory&) + 96
35 swift-ide-test           0x0000000106390e0d doCodeCompletionImpl(swift::CodeCompletionCallbacksFactory*, swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool)::$_0::operator()(swift::CompilerInstance&, bool) const + 141
36 swift-ide-test           0x0000000106390d6c void llvm::function_ref<void (swift::CompilerInstance&, bool)>::callback_fn<doCodeCompletionImpl(swift::CodeCompletionCallbacksFactory*, swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool)::$_0>(long, swift::CompilerInstance&, bool) + 76
37 swift-ide-test           0x0000000106ee9998 llvm::function_ref<void (swift::CompilerInstance&, bool)>::operator()(swift::CompilerInstance&, bool) const + 88
38 swift-ide-test           0x0000000106ee9c7f 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)>) + 623
39 swift-ide-test           0x0000000106eea63e 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)>) + 670
40 swift-ide-test           0x0000000106390ad4 doCodeCompletionImpl(swift::CodeCompletionCallbacksFactory*, swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool) + 1076
41 swift-ide-test           0x0000000106366757 doCodeCompletion(swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool, bool, bool, bool) + 535
42 swift-ide-test           0x0000000106362858 main + 7720
43 libdyld.dylib            0x00007fff20340631 start + 1
Abort trap: 6
@nathawes
Copy link
Collaborator Author

@swift-ci create

@ahoppen
Copy link
Contributor

ahoppen commented Mar 22, 2021

Fixed in #36495

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the compiler The Swift compiler in itself label Dec 13, 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 compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software 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

3 participants