Skip to content

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

2 participants