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-6354] Compiler should warn if a setter does not use newValue #48904

Closed
beccadax opened this issue Nov 10, 2017 · 1 comment
Closed

[SR-6354] Compiler should warn if a setter does not use newValue #48904

beccadax opened this issue Nov 10, 2017 · 1 comment
Labels
compiler The Swift compiler in itself improvement

Comments

@beccadax
Copy link
Contributor

Previous ID SR-6354
Radar None
Original Reporter @beccadax
Type Improvement
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: 86f0040d2fe7629e764905b46d4f068f

duplicates:

  • SR-964 Warn if a computed property setter doesn't reference the new value

Issue Description:

Another developer recently mentioned that he spent two hours debugging a problem that came down to a property like this:

var foo: Foo {
  set { underlyingComponent.foo = foo } // this should have been `= newValue` ...
  get { return underlyingComponent.foo }
}

The compiler could have diagnosed this mistake by noticing that the newValue parameter was never referenced in the setter. It is difficult to imagine a setter which would not need to reference its newValue, and on the off chance somebody really does need to do so, you could silence the warning by ignoring the parameter with "set (_) {…}".

@beccadax
Copy link
Contributor Author

Turns out this is a duplicate of something I didn't find in my search.

@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
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

1 participant