Skip to content

Commit 0b0b2cf

Browse files
committed
ruff format
1 parent fd1f1e7 commit 0b0b2cf

File tree

3 files changed

+184
-169
lines changed

3 files changed

+184
-169
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();

crates/vm/src/vm/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,10 +864,10 @@ impl VirtualMachine {
864864
// Pre-existing cycle detected - all exceptions on the path were visited
865865
break;
866866
}
867-
if slow_update_toggle {
868-
if let Some(slow_context) = slow_o.__context__() {
869-
slow_o = slow_context;
870-
}
867+
if slow_update_toggle
868+
&& let Some(slow_context) = slow_o.__context__()
869+
{
870+
slow_o = slow_context;
871871
}
872872
slow_update_toggle = !slow_update_toggle;
873873
}

0 commit comments

Comments
 (0)