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-6613] Warn when shadowing an instance variable with a local variable #49162

Open
swift-ci opened this issue Dec 14, 2017 · 0 comments
Open
Labels
compiler The Swift compiler in itself improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6613
Radar rdar://problem/22872819
Original Reporter rgov (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: 6412f3a94c91e27f72641fcd6c55e90c

relates to:

  • SR-1687 Swift does not warn about shadowing
  • SR-8524 Shadowing in protocols leads to difficult to find bugs

Issue Description:

I had a bug that was hard to track down. It turns out in a method, I had accidentally created a new variable at the method body scope with `let foo = ...` instead of assigning to the instance variable `foo`.

I feel that while this should be permitted, it would be a good idea to warn about it. I would be OK with having to use some keyword that makes it explicit I'm shadowing something else.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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