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-14739] Completion fails with assertion failure "Result && "ReturnStmt doesn't have a result")" #57089

Closed
ahoppen opened this issue Jun 8, 2021 · 2 comments
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 Jun 8, 2021

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

md5: 66822780e30aa70c1880bf81f6888d9e

Issue Description:

The following test case hits an assertion failure Assertion failed: (Result && "ReturnStmt doesn't have a result")

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

struct ItemDetailView {
  private var itemViewModel: Int
  @ViewBuilder2 var body: some View2 {
    Text2()
      .environmens(\.horizontalSizeClass2, .#^COMPLETE^#regular)
      .onDisappeaq {
        self.itemViewModel
      }
  }
}

protocol View2 {}

extension View2 {
  func onDisappeaq(perform action: (() -> Swift.Void)? = nil) -> some View2 {
    fatalError()
  }
}

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

enum Foo {
  case regular
}

struct EnvironmentValues2 {
  public var horizontalSizeClass2: Foo
}

public struct Text2 : View2 {
  public init() { fatalError() }
  func environmens<V>(_ keyPath: WritableKeyPath<EnvironmentValues2, V>, _ value: V) -> some View2 { fatalError() }
}

Stack trace:

Assertion failed: (Result && "ReturnStmt doesn't have a result"), function getResult, file /Users/alex/swift-src/swift/include/swift/AST/Stmt.h, line 218.
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 --source-filename /Users/alex/swift-src/swift/test/SourceKit/test.swift --code-completion-token=COMPLETE
1.  While performing new completion
2.  While evaluating request CodeCompletionSecondPassRequest(source_file "/Users/alex/swift-src/swift/test/SourceKit/test.swift", )
3.  While code-completion expression at [/Users/alex/swift-src/swift/test/SourceKit/test.swift:6:5 - line:10:7] RangeText="Text2()
      .environmens(\.horizontalSizeClass2, .regular)
      .onDisappeaq {
        self.itemViewModel
      "
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           0x00000001148cdc67 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-ide-test           0x00000001148cca88 llvm::sys::RunSignalHandlers() + 248
2  swift-ide-test           0x00000001148ce296 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff2039bd7d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603339975508640
5  libsystem_c.dylib        0x00007fff202ab411 abort + 120
6  libsystem_c.dylib        0x00007fff202aa7e8 err + 0
7  swift-ide-test           0x0000000114d7fbf3 swift::ASTVisitor<(anonymous namespace)::ClosureConstraintGenerator, void, void, void, void, void, void>::visit(swift::Stmt*) (.cold.3) + 35
8  swift-ide-test           0x0000000110bf9154 swift::ASTVisitor<(anonymous namespace)::ClosureConstraintGenerator, void, void, void, void, void, void>::visit(swift::Stmt*) + 660
9  swift-ide-test           0x0000000110bf8f28 swift::ASTVisitor<(anonymous namespace)::ClosureConstraintGenerator, void, void, void, void, void, void>::visit(swift::Stmt*) + 104
10 swift-ide-test           0x0000000110bf8f28 swift::ASTVisitor<(anonymous namespace)::ClosureConstraintGenerator, void, void, void, void, void, void>::visit(swift::Stmt*) + 104
11 swift-ide-test           0x0000000110bf8eac swift::constraints::ConstraintSystem::generateConstraints(swift::ClosureExpr*, swift::Type) + 44
12 swift-ide-test           0x0000000110c2d672 swift::constraints::ConstraintSystem::resolveClosure(swift::TypeVariableType*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 5394
13 swift-ide-test           0x0000000110c2beba swift::constraints::ConstraintSystem::matchTypesBindTypeVar(swift::TypeVariableType*, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder, llvm::function_ref<swift::constraints::ConstraintSystem::TypeMatchResult ()>) + 1546
14 swift-ide-test           0x0000000110c22b9f swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 2143
15 swift-ide-test           0x0000000110bf384e swift::constraints::TypeVariableBinding::attempt(swift::constraints::ConstraintSystem&) const + 398
16 swift-ide-test           0x0000000110c6838c swift::constraints::BindingStep<swift::constraints::TypeVarBindingProducer>::take(bool) + 428
17 swift-ide-test           0x0000000110c57de1 swift::constraints::ConstraintSystem::solveImpl(llvm::SmallVectorImpl<swift::constraints::Solution>&) + 449
18 swift-ide-test           0x0000000110c5a748 swift::constraints::ConstraintSystem::solveForCodeCompletion(swift::constraints::SolutionApplicationTarget&, llvm::SmallVectorImpl<swift::constraints::Solution>&) + 328
19 swift-ide-test           0x0000000110d817a3 swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SolutionApplicationTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>)::$_2::operator()(swift::constraints::SolutionApplicationTarget&) const + 115
20 swift-ide-test           0x0000000110d815e6 swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SolutionApplicationTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>) + 838
21 swift-ide-test           0x0000000110d829f6 swift::UnresolvedMemberTypeCheckCompletionCallback::fallbackTypeCheck(swift::DeclContext*) + 166
22 swift-ide-test           0x00000001101f25ba (anonymous namespace)::CodeCompletionCallbacksImpl::doneParsing() + 874
23 swift-ide-test           0x00000001111047c8 swift::Parser::performCodeCompletionSecondPassImpl(swift::CodeCompletionDelayedDeclState&) + 888
24 swift-ide-test           0x0000000111104348 swift::CodeCompletionSecondPassRequest::evaluate(swift::Evaluator&, swift::SourceFile*, swift::CodeCompletionCallbacksFactory*) const + 232
25 swift-ide-test           0x000000011110ea1f llvm::Expected<swift::CodeCompletionSecondPassRequest::OutputType> swift::Evaluator::getResultUncached<swift::CodeCompletionSecondPassRequest>(swift::CodeCompletionSecondPassRequest const&) + 271
26 swift-ide-test           0x0000000111104157 swift::CodeCompletionSecondPassRequest::OutputType swift::evaluateOrDefault<swift::CodeCompletionSecondPassRequest>(swift::Evaluator&, swift::CodeCompletionSecondPassRequest, swift::CodeCompletionSecondPassRequest::OutputType) + 55
27 swift-ide-test           0x0000000110217b01 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
28 swift-ide-test           0x0000000110217f98 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
29 swift-ide-test           0x000000010fe2dac0 doCodeCompletionImpl(swift::CodeCompletionCallbacksFactory*, swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool) + 1376
30 swift-ide-test           0x000000010fe20560 main + 26144
31 libdyld.dylib            0x00007fff20371f3d start + 1
32 libdyld.dylib            0x000000000000000b start + 18446603339975680207
@typesanitizer
Copy link

@swift-ci create

@ahoppen
Copy link
Contributor Author

ahoppen commented Mar 17, 2022

Fixed by #41846

@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

3 participants