swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.65k stars 10.38k forks source link

Assertion failed: ((conformingReplacementType->is<ErrorType>() || conformingReplacementType->is<SubstitutableType>() || conformingReplacementType->is<DependentMemberType>() || conformingReplacementType->hasTypeVariable()) && "replacement requires looking up a concrete conformance") #75898

Open ahoppen opened 3 months ago

ahoppen commented 3 months ago

The following new test case causes an assertion failure

// RUN: %batch-code-completion

extension Result {
  typealias Value = Success

  init(value: Value) {}

  func tryMap() {
    return flatMap { value in }#^COMPLETE^#
  }
}

Stack trace:

Assertion failed: ((conformingReplacementType->is<ErrorType>() || conformingReplacementType->is<SubstitutableType>() || conformingReplacementType->is<DependentMemberType>() || conformingReplacementType->hasTypeVariable()) && "replacement requires looking up a concrete conformance"), function operator(), file TypeSubstitution.cpp, line 253.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /Users/alex/sbin/swift-ide-test -code-completion -source-filename /private/var/folders/9_/vrdblnzs0m762wbv2hsryrkr0000gn/T/reduced.swift -code-completion-token COMPLETE
1.  While performing new IDE inspection
2.  While evaluating request IDEInspectionSecondPassRequest(source_file "/private/var/folders/9_/vrdblnzs0m762wbv2hsryrkr0000gn/T/reduced.swift", )
3.  While evaluating request TypeRelationCheckRequest(Check if <(Result<_, Failure>.Value) -> Result<_, Failure>, ()> is ConvertTo )
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           0x0000000106909f4c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-ide-test           0x0000000106908314 llvm::sys::RunSignalHandlers() + 112
2  swift-ide-test           0x000000010690a5e0 SignalHandler(int) + 352
3  libsystem_platform.dylib 0x0000000187755184 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018771df70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018762a908 abort + 128
6  libsystem_c.dylib        0x0000000187629c1c err + 0
7  swift-ide-test           0x0000000106a01978 swift::DependentMemberType::substBaseType(swift::Type, llvm::function_ref<swift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolDecl*)>, swift::SubstOptions) (.cold.1) + 0
8  swift-ide-test           0x00000001014500fc swift::MakeAbstractConformanceForGenericType::operator()(swift::CanType, swift::Type, swift::ProtocolDecl*) const + 848
9  swift-ide-test           0x0000000101451390 swift::InFlightSubstitution::lookupConformance(swift::CanType, swift::Type, swift::ProtocolDecl*, unsigned int) + 36
10 swift-ide-test           0x000000010139c4d4 swift::ProtocolConformanceRef::subst(swift::Type, swift::InFlightSubstitution&) const + 572
11 swift-ide-test           0x0000000101419620 swift::SubstitutionMap::subst(swift::InFlightSubstitution&) const + 816
12 swift-ide-test           0x000000010145467c std::__1::optional<swift::Type> llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, unsigned int, swift::InFlightSubstitution&)::$_4>(long, swift::TypeBase*) + 1168
13 swift-ide-test           0x000000010142b768 swift::Type::transformWithPosition(swift::TypePosition, llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>) const + 96
14 swift-ide-test           0x000000010142c5c4 swift::Type::transformWithPosition(swift::TypePosition, llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>) const + 3772
15 swift-ide-test           0x000000010142db80 swift::Type::transformRec(llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*)>) const + 36
16 swift-ide-test           0x000000010145169c substType(swift::Type, unsigned int, swift::InFlightSubstitution&) + 324
17 swift-ide-test           0x0000000101450e80 swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<swift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolDecl*)>, swift::SubstOptions) const + 328
18 swift-ide-test           0x000000010252b804 swift::TypeChecker::typesSatisfyConstraint(swift::Type, swift::Type, bool, swift::constraints::ConstraintKind, swift::DeclContext*, bool*) + 216
19 swift-ide-test           0x000000010154a49c swift::TypeRelationCheckRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeRelationCheckRequest, swift::TypeRelationCheckRequest::OutputType swift::evaluateOrDefault<swift::TypeRelationCheckRequest>(swift::Evaluator&, swift::TypeRelationCheckRequest, swift::TypeRelationCheckRequest::OutputType)::'lambda'()>(swift::TypeRelationCheckRequest const&, swift::TypeRelationCheckRequest::OutputType swift::evaluateOrDefault<swift::TypeRelationCheckRequest>(swift::Evaluator&, swift::TypeRelationCheckRequest, swift::TypeRelationCheckRequest::OutputType)::'lambda'()) + 220
20 swift-ide-test           0x000000010154a32c swift::TypeRelationCheckRequest::OutputType swift::Evaluator::getResultCached<swift::TypeRelationCheckRequest, swift::TypeRelationCheckRequest::OutputType swift::evaluateOrDefault<swift::TypeRelationCheckRequest>(swift::Evaluator&, swift::TypeRelationCheckRequest, swift::TypeRelationCheckRequest::OutputType)::'lambda'(), (void*)0>(swift::TypeRelationCheckRequest const&, swift::TypeRelationCheckRequest::OutputType swift::evaluateOrDefault<swift::TypeRelationCheckRequest>(swift::Evaluator&, swift::TypeRelationCheckRequest, swift::TypeRelationCheckRequest::OutputType)::'lambda'()) + 436
21 swift-ide-test           0x000000010153aa78 swift::isConvertibleTo(swift::Type, swift::Type, bool, swift::DeclContext&) + 76
22 swift-ide-test           0x0000000101513ac8 swift::ide::CodeCompletionResultType::calculateTypeRelation(swift::ide::ExpectedTypeContext const*, swift::DeclContext const*, swift::ide::USRBasedTypeContext const*) const + 1152
23 swift-ide-test           0x0000000101522890 swift::ide::CompletionLookup::addCompoundFunctionNameIfDesiable(swift::AbstractFunctionDecl*, swift::DeclVisibilityKind, swift::DynamicLookupInfo) + 800
24 swift-ide-test           0x0000000101522ed4 swift::ide::CompletionLookup::foundDecl(swift::ValueDecl*, swift::DeclVisibilityKind, swift::DynamicLookupInfo) + 692
25 swift-ide-test           0x0000000102475454 lookupVisibleMemberDecls(swift::Type, swift::SourceLoc, swift::VisibleDeclConsumer&, swift::DeclContext const*, (anonymous namespace)::LookupState, swift::DeclVisibilityKind) + 2140
26 swift-ide-test           0x0000000102474bd0 swift::lookupVisibleMemberDecls(swift::VisibleDeclConsumer&, swift::Type, swift::SourceLoc, swift::DeclContext const*, bool, bool, bool, swift::GenericSignature) + 160
27 swift-ide-test           0x00000001015242f4 swift::ide::CompletionLookup::getValueExprCompletions(swift::Type, swift::ValueDecl*, bool) + 444
28 swift-ide-test           0x000000010155ffcc swift::ide::PostfixCompletionCallback::collectResults(swift::SourceLoc, bool, bool, bool, swift::ide::CodeCompletionContext&) + 860
29 swift-ide-test           0x00000001014fe250 (anonymous namespace)::CodeCompletionCallbacksImpl::doneParsing(swift::SourceFile*) + 776
30 swift-ide-test           0x000000010285970c swift::Parser::performIDEInspectionSecondPassImpl(swift::IDEInspectionDelayedDeclState&) + 600
31 swift-ide-test           0x00000001028593c4 swift::IDEInspectionSecondPassRequest::evaluate(swift::Evaluator&, swift::SourceFile*, swift::IDEInspectionCallbacksFactory*) const + 168
32 swift-ide-test           0x000000010285f6c0 swift::IDEInspectionSecondPassRequest::OutputType swift::Evaluator::getResultUncached<swift::IDEInspectionSecondPassRequest, swift::IDEInspectionSecondPassRequest::OutputType swift::evaluateOrDefault<swift::IDEInspectionSecondPassRequest>(swift::Evaluator&, swift::IDEInspectionSecondPassRequest, swift::IDEInspectionSecondPassRequest::OutputType)::'lambda'()>(swift::IDEInspectionSecondPassRequest const&, swift::IDEInspectionSecondPassRequest::OutputType swift::evaluateOrDefault<swift::IDEInspectionSecondPassRequest>(swift::Evaluator&, swift::IDEInspectionSecondPassRequest, swift::IDEInspectionSecondPassRequest::OutputType)::'lambda'()) + 232
33 swift-ide-test           0x000000010285930c swift::performIDEInspectionSecondPass(swift::SourceFile&, swift::IDEInspectionCallbacksFactory&) + 52
34 swift-ide-test           0x00000001015845f4 void llvm::function_ref<void (swift::ide::IDEInspectionInstanceResult const&, llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::CodeCompleteResult>)>)>::callback_fn<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>)>)::$_1::operator()(swift::ide::CancellableResult<swift::ide::IDEInspectionInstanceResult>) const::'lambda'(auto&, auto)>(long, swift::ide::IDEInspectionInstanceResult const&, llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::CodeCompleteResult>)>) + 896
35 swift-ide-test           0x0000000101583c88 void swift::ide::CancellableResult<swift::ide::IDEInspectionInstanceResult>::mapAsync<swift::ide::CodeCompleteResult>(llvm::function_ref<void (swift::ide::IDEInspectionInstanceResult const&, llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::CodeCompleteResult>)>)>, llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::CodeCompleteResult>)>) + 84
36 swift-ide-test           0x0000000101583bd0 void llvm::function_ref<void (swift::ide::CancellableResult<swift::ide::IDEInspectionInstanceResult>)>::callback_fn<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>)>)::$_1>(long, swift::ide::CancellableResult<swift::ide::IDEInspectionInstanceResult>) + 128
37 swift-ide-test           0x0000000101582eac swift::ide::IDEInspectionInstance::performNewOperation(std::__1::optional<llvm::hash_code>, swift::CompilerInvocation&, 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>)>) + 928
38 swift-ide-test           0x0000000101583650 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>)>) + 552
39 swift-ide-test           0x0000000101583890 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>)>) + 216
40 swift-ide-test           0x000000010102770c bool llvm::function_ref<bool (CompletionLikeOperationParams)>::callback_fn<doCodeCompletion(swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool, bool, bool, bool, bool, bool, bool)::$_8>(long, CompletionLikeOperationParams) + 344
41 swift-ide-test           0x00000001010273a4 performWithCompletionLikeOperationParams(swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool, llvm::function_ref<bool (CompletionLikeOperationParams)>) + 1220
42 swift-ide-test           0x0000000101015208 doCodeCompletion(swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool, bool, bool, bool, bool, bool, bool) + 444
43 swift-ide-test           0x0000000101010e8c main + 10072
44 dyld                     0x000000018739b274 start + 2840
ahoppen commented 2 months ago

Issue no longer seen in the SourceKit stress tester. Seems to have been fixed.