Skip to content

Run the VarDeclUsageChecker on top level code declarations. #6971

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

Closed
wants to merge 2 commits into from

Conversation

KingOfBrian
Copy link
Contributor

Run the VarDeclUsageChecker on top level code declarations so unused variables correctly generate warnings.

Resolves SR-2115.

@KingOfBrian
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more tests would be nice -- cover the other things that the VarDeclUsageChecker can diagnose

…when all of the top level declarations have been parsed.
@KingOfBrian
Copy link
Contributor Author

Good eye @slavapestov -- the additional tests definitely showed some issues. I had one misconception about what a TLCD was, and also didn't realize that the method was being pumped and would execute with partial state. I changed the code to run only on the last pump, and to walk all of the TLCD with one VarDeclUsageChecker.

@KingOfBrian
Copy link
Contributor Author

KingOfBrian commented Jan 23, 2017

Wow, should of ran the test suite locally! This fix uncovered 70 unexpected failures in the unit tests. They all seem like valid warnings, but it's going to take a few to comb through them all. I'm going to convert to let whenever suggested, but add an empty array to use all the variables instead of replacing with _ since that may alter some of the test behavior.

@KingOfBrian
Copy link
Contributor Author

So I realized I need to be smarter with the top level unused-var declaration checks -- this will still incorrectly warn on cross-file globals. I'm going to close this for now so I can make sure I understand everything. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants