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-14887] Assertion failure hasCompletionExpr when completing key path in result builder #57234

Closed
ahoppen opened this issue Jul 7, 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 7, 2021

Previous ID SR-14887
Radar rdar://80271346
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: a3bab869b89943392bfcefd65068d8cf

Issue Description:

The following test case fails with an assertion failure Assertion failed: (hasCompletionExpr())

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

protocol View2 {}

@resultBuilder public struct ViewBuilder2 {
  public static func buildBlock<Content>(_ content: Content) -> Content where Content : View2 { fatalError() }
  public static func buildIf<Content>(_ content: Content?) -> Content? where Content : View2 { fatalError() }
}

struct VStack2<Content>: View2 {
    init(@ViewBuilder2 view: () -> Content) {}
}

struct TodayBirthdaysSection {
    @ViewBuilder2 var body: some View2 {
        VStack2 {
            if true {
                var villagers: [Int] = []
                villagers.map(\.#^COMPLETE^#id)
            }
        }
    }
}

Stack trace

0  swift-ide-test           0x000000010a9afa87 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-ide-test           0x000000010a9ae988 llvm::sys::RunSignalHandlers() + 248
2  swift-ide-test           0x000000010a9b00b6 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff20552d7d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603339973710496
5  libsystem_c.dylib        0x00007fff20462411 abort + 120
6  libsystem_c.dylib        0x00007fff204617e8 err + 0
7  swift-ide-test           0x000000010aee8503 swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SolutionApplicationTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>)::$_2::operator()(swift::constraints::SolutionApplicationTarget&) const (.cold.1) + 35
8  swift-ide-test           0x0000000106e5bf7b swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SolutionApplicationTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>)::$_2::operator()(swift::constraints::SolutionApplicationTarget&) const + 1627
9  swift-ide-test           0x0000000106e5b7d6 swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SolutionApplicationTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>) + 838
10 swift-ide-test           0x0000000106e703e1 swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 305
11 swift-ide-test           0x0000000106e7022e swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 78
12 swift-ide-test           0x0000000106f39db8 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 4824
13 swift-ide-test           0x0000000106f38aa0 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 128
14 swift-ide-test           0x0000000106f36a0f (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 143
15 swift-ide-test           0x0000000106f36e5e swift::TypeCheckASTNodeAtLocRequest::evaluate(swift::Evaluator&, swift::DeclContext*, swift::SourceLoc) const + 542
16 swift-ide-test           0x0000000106f747c3 llvm::Expected<swift::TypeCheckASTNodeAtLocRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckASTNodeAtLocRequest>(swift::TypeCheckASTNodeAtLocRequest const&) + 243
17 swift-ide-test           0x0000000106f6e607 swift::TypeCheckASTNodeAtLocRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckASTNodeAtLocRequest>(swift::Evaluator&, swift::TypeCheckASTNodeAtLocRequest, swift::TypeCheckASTNodeAtLocRequest::OutputType) + 55
18 swift-ide-test           0x0000000106f6e5b1 swift::typeCheckASTNodeAtLoc(swift::DeclContext*, swift::SourceLoc) + 65
19 swift-ide-test           0x0000000106f36e1e swift::TypeCheckASTNodeAtLocRequest::evaluate(swift::Evaluator&, swift::DeclContext*, swift::SourceLoc) const + 478
20 swift-ide-test           0x0000000106f747c3 llvm::Expected<swift::TypeCheckASTNodeAtLocRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckASTNodeAtLocRequest>(swift::TypeCheckASTNodeAtLocRequest const&) + 243
21 swift-ide-test           0x0000000106f6e607 swift::TypeCheckASTNodeAtLocRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckASTNodeAtLocRequest>(swift::Evaluator&, swift::TypeCheckASTNodeAtLocRequest, swift::TypeCheckASTNodeAtLocRequest::OutputType) + 55
22 swift-ide-test           0x0000000106f6e5b1 swift::typeCheckASTNodeAtLoc(swift::DeclContext*, swift::SourceLoc) + 65
23 swift-ide-test           0x00000001062db7a3 swift::ide::typeCheckContextAt(swift::DeclContext*, swift::SourceLoc) + 771
24 swift-ide-test           0x00000001062b3f76 (anonymous namespace)::CodeCompletionCallbacksImpl::doneParsing() + 854
25 swift-ide-test           0x00000001071e4208 swift::Parser::performCodeCompletionSecondPassImpl(swift::CodeCompletionDelayedDeclState&) + 888
26 swift-ide-test           0x00000001071e3d88 swift::CodeCompletionSecondPassRequest::evaluate(swift::Evaluator&, swift::SourceFile*, swift::CodeCompletionCallbacksFactory*) const + 232
27 swift-ide-test           0x00000001071ee48f llvm::Expected<swift::CodeCompletionSecondPassRequest::OutputType> swift::Evaluator::getResultUncached<swift::CodeCompletionSecondPassRequest>(swift::CodeCompletionSecondPassRequest const&) + 271
28 swift-ide-test           0x00000001071e3b97 swift::CodeCompletionSecondPassRequest::OutputType swift::evaluateOrDefault<swift::CodeCompletionSecondPassRequest>(swift::Evaluator&, swift::CodeCompletionSecondPassRequest, swift::CodeCompletionSecondPassRequest::OutputType) + 55
29 swift-ide-test           0x00000001062d9981 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
30 swift-ide-test           0x00000001062d9e18 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
31 swift-ide-test           0x0000000105ed7750 doCodeCompletionImpl(swift::CodeCompletionCallbacksFactory*, swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool) + 1376
32 swift-ide-test           0x0000000105eca080 main + 26192
33 libdyld.dylib            0x00007fff20528f5d start + 1
34 libdyld.dylib            0x000000000000000c start + 18446603339973882032
/Users/alex/swift-src/nbuild/Release+Asserts/tools/swift/test-macosx-x86_64/SourceKit/Output/test.swift.script: line 1: 28158 Abort trap: 6           '/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 -source-filename /Users/alex/swift-src/swift/test/SourceKit/test.swift -code-completion-token COMPLETE
@ahoppen
Copy link
Contributor Author

ahoppen commented Jul 8, 2021

Fixed in #38299

@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