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-10000] Incorrect diagnostic invoking inline closure with missing parens #52403

Closed
JaviSoto opened this issue Feb 26, 2019 · 2 comments
Closed
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

@JaviSoto
Copy link
Contributor

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

Swift 4.2 in Xcode 10.1 as well as the Swift 5 version in Xcode 10.2 Beta 3.

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

md5: 2e4adb2aaa8d36c75363a6abeaf24f27

Issue Description:

The following code produces a diagnostic with a bogus message and in the wrong line:

func f(param: Int) -> Int {
  return param
}

var foo = 0
var bar = ""

foo = f(param: 1)
{ bar = "bar" }()

Untitled 4.swift:8:27: error: extra argument 'param' in call
foo = f(param: 1)

The error is in the following line, because it's missing parenthesis, it should be:

({ bar = "bar" })()

I believe it must think that the following line is a closure that's being passed to the f function, but even if that's the case, the argument "param" is not an "extra argument", unless I'm misunderstanding it.

@lilyball
Copy link
Mannequin

lilyball mannequin commented Feb 26, 2019

The existence of the error is correct. The wording is confusing. It should just say error: extra argument in call because the extra argument is the trailing closure, not the initial parameter, and the location indicator should point at the closure.

@gregomni
Copy link
Collaborator

gregomni commented Aug 5, 2019

Fixed in #26488

@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