Skip to content

Commit b4b74a8

Browse files
authored
Merge pull request RustPython#4338 from yt2b/fix_symbol_scope
Fix panic about warlus operator inside mutiple comprehensions.
2 parents 154b72c + 65d2aca commit b4b74a8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/codegen/src/symboltable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl SymbolTableAnalyzer {
483483
};
484484
} else {
485485
let mut cloned_sym = symbol.clone();
486-
cloned_sym.scope = SymbolScope::Local;
486+
cloned_sym.scope = SymbolScope::Cell;
487487
last.0.insert(cloned_sym.name.to_owned(), cloned_sym);
488488
}
489489
}

extra_tests/snippets/syntax_comprehension.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@
4141
assert 'c' not in locals()
4242
assert 'b' not in globals()
4343
assert 'c' not in globals()
44+
45+
46+
def f():
47+
# Test no panic occured.
48+
[[x := 1 for j in range(5)] for i in range(5)]

0 commit comments

Comments
 (0)