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-13002] Assertion failed: (numMissing > 0 || numExtra > 0 || numWrong > 0), function diagnoseArgumentLabelError #55447

Closed
nathawes opened this issue Jun 13, 2020 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. 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 type checker Area → compiler: Semantic analysis

Comments

@nathawes
Copy link
Collaborator

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

md5: b98dfd15f54c50f14f51ed3288f73d84

Issue Description:

Compile the below to reproduce:

extension Dictionary {
    static func fromArray<K, V>(_ arrayOfTuples: [(K, V)]) -> [K:V] {}

    func flatMapDict<MK, MV>(transform: (Key, Value) -> (Int, Int)) -> [MK: MV] {
        return Dictionary.fromArray(
            compactMap {
                let (k, v) = transform($0

Also crashes sourcekit.

Trace:

Assertion failed: (numMissing > 0 || numExtra > 0 || numWrong > 0), function diagnoseArgumentLabelError, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/Sema/MiscDiagnostics.cpp, line 1779.
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff6b42d33a __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff6b4e9e60 pthread_kill + 430
2   libsystem_c.dylib               0x00007fff6b3b48a2 __abort + 139
3   libsystem_c.dylib               0x00007fff6b3b4817 abort + 135
4   libsystem_c.dylib               0x00007fff6b3b3ac6 __assert_rtn + 314
5   swift                           0x0000000107b74803 swift::diagnoseArgumentLabelError(swift::ASTContext&, swift::Expr*, llvm::ArrayRef<swift::Identifier>, bool, swift::InFlightDiagnostic*) (.cold.1) + 35
6   swift                           0x0000000104234ebd swift::diagnoseArgumentLabelError(swift::ASTContext&, swift::Expr*, llvm::ArrayRef<swift::Identifier>, bool, swift::InFlightDiagnostic*) + 4157
7   swift                           0x00000001041b042b swift::constraints::LabelingFailure::diagnoseAsError() + 171
8   swift                           0x00000001041a3833 swift::constraints::RelabelArguments::diagnose(swift::constraints::Solution const&, bool) const + 67
9   swift                           0x000000010410e8f1 swift::constraints::ConstraintSystem::applySolutionFixes(swift::constraints::Solution const&) + 1889
10  swift                           0x000000010410f17d swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SolutionApplicationTarget) + 61
11  swift                           0x000000010428a6fd swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 557
12  swift                           0x000000010428aad8 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, swift::Type, swift::PatternBindingDecl*, unsigned int) + 120
13  swift                           0x000000010428ad63 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, swift::Type) + 371
14  swift                           0x00000001043316f1 swift::PatternBindingEntryRequest::evaluate(swift::Evaluator&, swift::PatternBindingDecl*, unsigned int) const + 641
15  swift                           0x000000010435ef35 llvm::Expected<swift::PatternBindingEntryRequest::OutputType> swift::Evaluator::getResultUncached<swift::PatternBindingEntryRequest>(swift::PatternBindingEntryRequest const&) + 357
16  swift                           0x000000010435ec93 llvm::Expected<swift::PatternBindingEntryRequest::OutputType> swift::Evaluator::getResultCached<swift::PatternBindingEntryRequest, (void*)0>(swift::PatternBindingEntryRequest const&) + 51
17  swift                           0x000000010435c348 swift::PatternBindingEntryRequest::OutputType swift::evaluateOrDefault<swift::PatternBindingEntryRequest>(swift::Evaluator&, swift::PatternBindingEntryRequest, swift::PatternBindingEntryRequest::OutputType) + 40
18  swift                           0x00000001042bd35f swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl*) + 2703
19  swift                           0x00000001042bc0ef (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 159
20  swift                           0x00000001042bc032 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 130
21  swift                           0x000000010432bc6a swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 2426
22  swift                           0x00000001043291c0 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 128
23  swift                           0x0000000104328fae swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 286
24  swift                           0x000000010410f3d9 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SolutionApplicationTarget) + 665
25  swift                           0x000000010428a6fd swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 557
26  swift                           0x000000010428a437 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 87
27  swift                           0x000000010432c923 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 5683
28  swift                           0x000000010432ce80 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 128
29  swift                           0x000000010432bd30 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 2624
30  swift                           0x00000001043291c0 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 128
31  swift                           0x0000000104328671 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1089
32  swift                           0x000000010432fb16 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest>(swift::TypeCheckFunctionBodyRequest const&) + 598
33  swift                           0x000000010432f64c llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 316
34  swift                           0x000000010432f4b6 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 118
35  swift                           0x0000000104327ef5 swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 37
36  swift                           0x0000000104327ea0 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 64
37  swift                           0x000000010435bd4e swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 382
38  swift                           0x000000010435ca65 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 453
39  swift                           0x000000010435c784 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 52
40  swift                           0x000000010435c6f6 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 118
41  swift                           0x000000010435bae0 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 32
42  swift                           0x00000001036cc78a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 90
43  swift                           0x00000001036cc67a swift::CompilerInstance::performSema() + 74
44  swift                           0x00000001035eee19 performCompile(swift::CompilerInstance&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 2329
45  swift                           0x00000001035ed519 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3529
46  swift                           0x0000000103589ccd main + 861
47  libdyld.dylib                   0x00007fff6b2e5cc9 start + 1
@nathawes
Copy link
Collaborator Author

@swift-ci create

@LucianoPAlmeida
Copy link
Collaborator

Ping @omochi 🙂

I think you are working on something related to relabel diagnostics right?

cc @xedin

@omochi
Copy link
Collaborator

omochi commented Jun 14, 2020

@LucianoPAlmeida I know well about this assertion.
I will investigate this issue tomorrow!

@omochi
Copy link
Collaborator

omochi commented Jun 15, 2020

I minimized the case.

func tr(_ a: Int, _ b: Int) {}

func f(x: (key: Int, value: Int)) {
  tr(x)
}

@omochi
Copy link
Collaborator

omochi commented Jun 15, 2020

I created patch.
#32380

@ahoppen
Copy link
Contributor

ahoppen commented Mar 19, 2021

Fixed in #36499.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added type checker Area → compiler: Semantic analysis CompilerCrash labels Sep 17, 2022
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. 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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants