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-11379] Type mismatch in trailing closure gives "Argument passed to call that takes no arguments" #53780

Closed
idrougge opened this issue Aug 27, 2019 · 6 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

@idrougge
Copy link

Previous ID SR-11379
Radar rdar://problem/54771412
Original Reporter @idrougge
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 10.3 (10G8), Swift 5

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

md5: 28adb9a6e0fd0671db51c4e9356e7671

relates to:

  • SR-6246 Wrong error emitted on first line of block

Issue Description:

Given the following (contrived) example:

let blutti = (0...5)
            .map { $0 * $0 }
            .filter { $0 > 6 }
            .map(String.init)
            .sorted(by: {(a: String, b: String) in a.uppercased() > b.uppercased() })

The code works out, but if one comments out the

.map(String.init)

line, one gets a warning, as can be expected, but a misleading one, namely: "Argument passed to call that takes no arguments"

This seems related to SR-6246

@belkadan
Copy link
Contributor

cc @xedin, @hborla. The diagnostic isn't exactly wrong since .sorted() (using Comparable) would have been valid code, but it certainly doesn't seem like it matches the user's intent.

@xedin
Copy link
Member

xedin commented Aug 28, 2019

@swift-ci create

@LucianoPAlmeida
Copy link
Collaborator

On a near master branch

let blutti = (0...5)
           .map { $0 * $0 } // error: unexpected error produced: cannot convert value of type 'Int' to closure result type 'String'
                      ^
            .filter { $0 > 6 } // error: unexpected error produced: cannot convert value of type 'String' to expected argument type 'Int'
            .sorted(by: {(a: String, b: String) in a.uppercased() > b.uppercased() })

Which seems correct to me 🙂
cc @xedin

@xedin
Copy link
Member

xedin commented Apr 6, 2020

Yeah, this is a much better error and describes what the problem is now. @idrougge, what do you think?

@idrougge
Copy link
Author

idrougge commented Apr 7, 2020

Yes, that looks much better.

@xedin
Copy link
Member

xedin commented Apr 7, 2020

Thank you! Let's resolve it then 🙂

@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