Skip to content

Conversation

sirbrillig
Copy link
Owner

#205 made it so that future uses of a variable after an array push are marked as defined. However, that is incorrect in the case of the array assignment being within the body of an if statement, an else statement, or a while, do, or for loop.

This modifies the code such that those cases are correctly reported as undefined variables.

Fixes #210

This actually matches the current behavior for non-array variables. It's
sometimes wrong, but further determination would require runtime
checking or static analysis.
@sirbrillig sirbrillig marked this pull request as ready for review September 15, 2020 20:43
@sirbrillig sirbrillig changed the title Fix if/loop condition undefined array Add tests for if/loop condition undefined array Sep 15, 2020
@sirbrillig sirbrillig merged commit c4fb5ee into master Sep 15, 2020
@sirbrillig sirbrillig deleted the fix-if-condition-undefined-array branch September 15, 2020 20:44
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.

Undefined array inside if condition or loop incorrectly marks other uses as read

1 participant