Skip to content

Commit dc9940f

Browse files
committed
ruff format
1 parent ebc3f95 commit dc9940f

File tree

2 files changed

+180
-165
lines changed

2 files changed

+180
-165
lines changed

crates/codegen/src/symboltable.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,25 @@ impl SymbolTableAnalyzer {
350350
symbol_table.symbols = info.0;
351351

352352
// PEP 709: Merge symbols from inlined comprehensions into parent scope
353-
// This allows the parent scope to see the comprehension's local variables
353+
// Only merge symbols that are actually bound in the comprehension,
354+
// not references to outer scope variables (Free symbols).
355+
const BOUND_FLAGS: SymbolFlags = SymbolFlags::ASSIGNED
356+
.union(SymbolFlags::PARAMETER)
357+
.union(SymbolFlags::ITER)
358+
.union(SymbolFlags::ASSIGNED_IN_COMPREHENSION);
359+
354360
for sub_table in sub_tables.iter() {
355361
if sub_table.comp_inlined {
356362
for (name, sub_symbol) in &sub_table.symbols {
357363
// Skip the .0 parameter - it's internal to the comprehension
358364
if name == ".0" {
359365
continue;
360366
}
367+
// Only merge symbols that are bound in the comprehension
368+
// Skip Free references to outer scope variables
369+
if !sub_symbol.flags.intersects(BOUND_FLAGS) {
370+
continue;
371+
}
361372
// If the symbol doesn't exist in parent, add it
362373
if !symbol_table.symbols.contains_key(name) {
363374
let mut symbol = sub_symbol.clone();

0 commit comments

Comments
 (0)