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-10126] Confusing Overload Error Message #52528

Closed
Mordil opened this issue Mar 17, 2019 · 4 comments
Closed

[SR-10126] Confusing Overload Error Message #52528

Mordil opened this issue Mar 17, 2019 · 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

@Mordil
Copy link

Mordil commented Mar 17, 2019

Previous ID SR-10126
Radar None
Original Reporter @Mordil
Type Bug
Status Resolved
Resolution Done
Environment

macOS Mojave v 10.14.4 Beta (18E194d)

Xcode 10.1 (10B61)

Toolchain: Swift 5.0 Snapshot 2019-03-10 (a)

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

md5: 96cbf05182aa2d5ac0a9024565764814

Issue Description:

I have two method overloads, one generic and one concrete, with explicit argument labels.

When invoking the concrete method, I get the compiler error:

Incorrect argument label in call (have 'command:', expected 'operation:') 
public protocol Connection { }

public protocol Pipeline {
    func enqueue<T>(operation: (Connection) -> T) -> Pipeline
    func enqueue(command: String, arguments: [String]) -> Pipeline
}

public final class AConn: Connection { }

public final class APipe: Pipeline {
    public func enqueue<T>(operation: (Connection) -> T) -> Pipeline {
        return self
    }

    public func enqueue(command: String, arguments: [String] = []) -> Pipeline {
        return self
    }
}

let pipe: Pipeline = APipe()
pipe.enqueue(command: "GET") // Compiler error with confusing message
@belkadan
Copy link
Contributor

There's no default argument in the protocol version of the method, so it's not completely surprising that the compiler thinks you're trying to call the generic version, but…the types don't match up there either.

@xedin, this is a trickier version of what we were talking about last week!

@xedin
Copy link
Member

xedin commented Mar 29, 2019

Looks the problem here is that this failure is diagnosed via type-check based diagnostics. It wouldn't be possible to diagnose this via fixes the same way, because there is no solution for "operation:" as you mentioned, since types don't line up... Once relabeling diagnostics are extended to support missing arguments this problem would be diagnosed correctly.

@Mordil
Copy link
Author

Mordil commented Mar 29, 2019

Ignore previous comment - posted to wrong Jira issue.

@xedin
Copy link
Member

xedin commented Sep 26, 2019

Resolves by #27362 Please use next available nightly build of master to verify and close.

@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

3 participants