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-6393] Warn on unused arguments #48943

Closed
jckarter opened this issue Nov 15, 2017 · 1 comment
Closed

[SR-6393] Warn on unused arguments #48943

jckarter opened this issue Nov 15, 2017 · 1 comment
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation feature A feature request or implementation function parameters Feature → declarations: function parameters name shadowing Feature: name shadowing type checker Area → compiler: Semantic analysis

Comments

@jckarter
Copy link
Member

Previous ID SR-6393
Radar rdar://problem/35534022
Original Reporter @jckarter
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI
Assignee None
Priority Medium

md5: ab9c9678ab456e51ea80f9ae9d159a46

duplicates:

  • SR-2849 Add a warning for unused parameters

Issue Description:

We warn when local let or var variables go unused, but not when function or closure arguments are unused. An intentionally-unused argument can be annotated by being given the binding name _.

var x = 0
func foo(x y: Int) {
  print(x) // oops, i probably meant `y`. an unused argument warning would be nice here
}

func foo(x _: Int) {
  print(x) // we can use `_` if this is what we meant
}
@belkadan
Copy link
Contributor

I think I prefer the _ = y idiom, since replacing the local name with _ means you can't document the parameter.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added name shadowing Feature: name shadowing function parameters Feature → declarations: function parameters feature A feature request or implementation type checker Area → compiler: Semantic analysis and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Feb 28, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation feature A feature request or implementation function parameters Feature → declarations: function parameters name shadowing Feature: name shadowing type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants