mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Fix scan_expression not to mark sequence as Load
This commit is contained in:
1 parent
036f464377
commit
e9c280368a
2 files changed
+15
-1
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
Reference in new issue
Block a user