Skip to content

Fix PSUseDeclaredVarsMoreThanAssignments when variable is assigned more than once to still give a warning - #836

Merged
James Truher (JamesWTruher) merged 2 commits into
PowerShell:developmentfrom
bergmeister:FixPSUseDeclaredVarsMoreThanAssignments_MultipleAssignments_Issue833
Jan 20, 2018
Merged

James Truher (JamesWTruher) merged 2 commits into
PowerShell:developmentfrom
bergmeister:FixPSUseDeclaredVarsMoreThanAssignments_MultipleAssignments_Issue833

Conversation

@bergmeister

@bergmeister Christoph Bergmeister (bergmeister) commented Dec 3, 2017 •

Copy link
Copy Markdown
Collaborator

To resolve Issue #833
Consider the case $a=1;$a=2. Then the inAssignment will be false for the 2nd ast because varsInAssignment already contains unly assignments to unique variables. Therefore no warning was produced. This PR makes it output a warning correctly by trying to cast it to an AssignmentStatementAst an then checks the text to see if it is actually the same variable.

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