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-7295] Misleading error message #49843

Closed
nevil opened this issue Mar 28, 2018 · 4 comments
Closed

[SR-7295] Misleading error message #49843

nevil opened this issue Mar 28, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@nevil
Copy link

nevil commented Mar 28, 2018

Previous ID SR-7295
Radar rdar://problem/38965072
Original Reporter @nevil
Type Bug
Status Closed
Resolution Done
Environment

Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9

swift-DEVELOPMENT-SNAPSHOT-2018-03-17-a.xctoolchain

swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-21-a.xctoolchain

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee @xedin
Priority Medium

md5: e3b89e1a826c748fefa3c35be1982431

Issue Description:

import Foundation

class A {

    func doSomething(a: (() -> Void)? = nil, completion: @escaping ((String, Error?) -> Void)) {}

    func doSomething(b: @escaping ((String, Error?, Bool) -> Void)) {}

    func a() {
        doSomething(a: nil, completion: { _ in })
    }
}

let a = A()

The code above results in a confusing error message:

a-new-bug.swift:10:41: error: extra argument 'completion' in call
        doSomething(a: nil, completion: { _ in })
                                        ^~~~~~~~

Removing the second doSomething changes the error to the more clear:

a-new-bug.swift:10:43: error: contextual closure type '(String, Error?) -> Void' expects 2 arguments, but 1 was used in closure body
        doSomething(a: nil, completion: { _ in })

It would be clearer if the second error message is the one produced in both cases.

There's also the confusing part that one _ or () can no longer be used to ignore a tuple parameter. The closure must be changed to (, _)

@belkadan
Copy link
Contributor

Still occurs in 4.1. cc @xedin

@xedin
Copy link
Member

xedin commented Mar 28, 2018

@swift-ci create

@swift-ci
Copy link
Collaborator

Comment by Ding Ye (JIRA)

Resolved in #17093

Thanks to Pavel Yaskevich.

@nevil
Copy link
Author

nevil commented Oct 29, 2019

Sorry for the delay.
I also confirmed that this is fixed.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants