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-5747] Unhelpful diagnostic ignoring non-existing argument in closure with captures #48317

Closed
NachoSoto opened this issue Aug 23, 2017 · 2 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

@NachoSoto
Copy link
Contributor

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

Swift version 4.0 (swiftlang-900.0.63.10 clang-900.0.36)

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

md5: d6bdbbe9ae007c530ed8f613a7fa64cb

Issue Description:

struct S {
    init(a: () -> Void) {}
}

class A {
    func f() {
        S { [unowned self] _ in 
            print("Test")
        }
    }
}
error: repl.swift:11:11: error: cannot convert value of type '(_) -> ()' to expected argument type '() -> Void'
        S { [unowned self] _ in
          ^~~~~~~~~~~~~~~~~~~~~~

Same implementation without capture list produces the correct diagnostic and fix it:

struct S {
    init(a: () -> Void) {}
}

class A {
    func f() {
        S { _ in 
            print("Test")
        }
    }
}
error: repl.swift:11:13: error: contextual closure type '() -> Void' expects 0 arguments, but 1 was used in closure body
        S { _ in
            ^~~~
@CodaFi
Copy link
Member

CodaFi commented Aug 23, 2017

#11575

@CodaFi
Copy link
Member

CodaFi commented Aug 23, 2017

Resolved by the merge of the linked pull request.

@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

2 participants