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

Fix array_walk pass-by-reference in 2.x #216

Merged
merged 4 commits into from
Nov 23, 2020
Merged

Fix array_walk pass-by-reference in 2.x #216

merged 4 commits into from
Nov 23, 2020

Conversation

sirbrillig
Copy link
Owner

@sirbrillig sirbrillig commented Nov 23, 2020

When marking a variable as used, we also check to see if that variable is a reference to another variable, and if so we mark the referenced variable as used also. However, it's possible to have a reference variable that doesn't reference anything until runtime.

Because markVariableAssignment will create a variable record if one does not exist, this caused non-existent variable records to be created for unbound reference variables. These references (since they didn't refer to a real variable) were always unused. This caused false positive warnings about unused variables.

This PR fixes the problem by making sure that the referenced variable exists before calling markVariableAssignment.

Fixes #215

@sirbrillig sirbrillig changed the base branch from master to 2.10 November 23, 2020 16:34
@sirbrillig sirbrillig changed the title Fix array_walk pass-by-reference Fix array_walk pass-by-reference in 2.x Nov 23, 2020
@sirbrillig sirbrillig marked this pull request as ready for review November 23, 2020 17:40
@sirbrillig sirbrillig merged commit 5048655 into 2.10 Nov 23, 2020
@sirbrillig sirbrillig deleted the fix-array-walk branch November 23, 2020 17:43
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.

array_walk with pass-by-reference causes false positive unused variable
1 participant