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

Allow global var assignment to count as a read #83

Merged
merged 6 commits into from
Apr 22, 2019

Conversation

sirbrillig
Copy link
Owner

@sirbrillig sirbrillig commented Apr 20, 2019

Typically when a variable is assigned a value within a scope, and then never used for any other purpose, it triggers an unused variable warning in this sniff. However, when the global keyword is used to import a variable into the scope, an assignment is a side-effect and therefore should count as using the variable (this is the same as the behavior of pass-by-reference). This PR fixes processScopeCloseForVariable() to support that behavior.

Fixes #81

@sirbrillig sirbrillig changed the title Fix global keyword Allow global var assignment to count as a read Apr 22, 2019
@sirbrillig sirbrillig merged commit a31046c into master Apr 22, 2019
@sirbrillig sirbrillig deleted the fix-global-keyword branch April 22, 2019 21:18
sirbrillig added a commit that referenced this pull request May 14, 2019
This is a follow-up to #83 which allows global assignments to count as
"reads" for the sake of marking unused variables.

Demonstrates the fix to #89
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.

Unused global variable warning when global variable is written to
1 participant