Fix scan_expression not to mark sequence as Load

This commit is contained in:
Jeong YunWon committed 2019-08-31 00:25:16 +09:00
1 parent 036f464377
commit e9c280368a
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -585,7 +585,7 @@ impl SymbolTableBuilder {
}
Bytes { .. } => {}
Tuple { elements } | Set { elements } | List { elements } | Slice { elements } => {
self.scan_expressions(elements, &ExpressionContext::Load)?;
self.scan_expressions(elements, context)?;
}
Comprehension { kind, generators } => {
match **kind {
+14
View File
@@ -27,3 +27,17 @@ z = [(9,), (10,)]
w = [x for x, in z]
assert w == [9, 10]
# generator targets shouldn't affect scopes out of comprehensions
[a for a in range(5)]
assert 'a' not in locals()
assert 'a' not in globals()
[b for a, b in [(1, 1), (2, 2)]]
assert 'b' not in locals()
assert 'b' not in globals()
{b: c for b, c in {1: 2}.items()}
assert 'b' not in locals()
assert 'c' not in locals()
assert 'b' not in globals()
assert 'c' not in globals()