Fix an analyzer crash with multiple list comprehensions in py3 #447
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The crash was caused by selecting the wrong child symbol table for the
list comprehension. Previously we were always selecting the first one in
the list of subtables. This is wrong if there is more than 1 list
comprehension, since each one gets its own subtable. This is works fine
if the list comprehension only uses symbols defined within itself or
symbols that are shared between it and the first list comprehension in
the enclosing scope, since that will resolve to the same value. The
specific error case we are fixing is when there is a list comprehension
that is not the first one that references a symbol from the enclosing
function scope that the first list comprehension does not reference.
Both the symbol tables and the ListComp node are annotated with a line
number attribute, by matching these up we can select the correct
subtable to go with our list comprehension. This is still naive, but is
better than what we had before.
fixes #412
cc @jamesls