Skip to content
Next Next commit
ASSIGNED -> DEF_LOCAL
  • Loading branch information
ShaharNaveh committed Jun 27, 2026
commit 7a532850831bbf7c5bd9a55916a9fa954367116b
2 changes: 1 addition & 1 deletion crates/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10809,7 +10809,7 @@ impl<'warnings> Compiler<'warnings> {
}
let is_local = sym
.flags
.intersects(SymbolFlags::ASSIGNED | SymbolFlags::ITER)
.intersects(SymbolFlags::DEF_LOCAL | SymbolFlags::ITER)
&& !sym.flags.contains(SymbolFlags::NONLOCAL);
if is_local {
pushed_locals.push(name.clone());
Expand Down
20 changes: 10 additions & 10 deletions crates/codegen/src/symboltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ bitflags! {
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct SymbolFlags: u16 {
const REFERENCED = 0x001; // USE
const ASSIGNED = 0x002; // DEF_LOCAL
const DEF_LOCAL = 2;
const PARAMETER = 0x004; // DEF_PARAM
const ANNOTATED = 0x008; // DEF_ANNOT
const IMPORTED = 0x010; // DEF_IMPORT
Expand All @@ -314,7 +314,7 @@ bitflags! {
const COMP_ITER = 0x400; // DEF_COMP_ITER
const COMP_CELL = 0x800; // DEF_COMP_CELL
const TYPE_PARAM = 0x1000; // DEF_TYPE_PARAM
const BOUND = Self::ASSIGNED.bits() | Self::PARAMETER.bits() | Self::IMPORTED.bits() | Self::ITER.bits() | Self::TYPE_PARAM.bits();
const BOUND = Self::DEF_LOCAL.bits() | Self::PARAMETER.bits() | Self::IMPORTED.bits() | Self::ITER.bits() | Self::TYPE_PARAM.bits();
}
}

Expand Down Expand Up @@ -3123,7 +3123,7 @@ impl SymbolTableBuilder {
.symbols
.entry(mangled.clone())
.or_insert_with(|| Symbol::new(mangled.as_str()));
symbol.flags.insert(SymbolFlags::ASSIGNED);
symbol.flags.insert(SymbolFlags::DEF_LOCAL);
return Ok(());
}
CompilerScope::Module => {
Expand Down Expand Up @@ -3283,7 +3283,7 @@ impl SymbolTableBuilder {
location,
});
}
if flags.contains(SymbolFlags::ASSIGNED) {
if flags.contains(SymbolFlags::DEF_LOCAL) {
return Err(SymbolTableError {
error: format!(
"name '{name}' is assigned to before global declaration"
Expand Down Expand Up @@ -3311,7 +3311,7 @@ impl SymbolTableBuilder {
location,
});
}
if flags.contains(SymbolFlags::ASSIGNED) {
if flags.contains(SymbolFlags::DEF_LOCAL) {
return Err(SymbolTableError {
error: format!(
"name '{name}' is assigned to before nonlocal declaration"
Expand Down Expand Up @@ -3370,7 +3370,7 @@ impl SymbolTableBuilder {
flags.insert(SymbolFlags::NONLOCAL);
}
SymbolUsage::Imported => {
flags.insert(SymbolFlags::ASSIGNED | SymbolFlags::IMPORTED);
flags.insert(SymbolFlags::DEF_LOCAL | SymbolFlags::IMPORTED);
}
SymbolUsage::Parameter => {
flags.insert(SymbolFlags::PARAMETER);
Expand All @@ -3389,13 +3389,13 @@ impl SymbolTableBuilder {
}
}
SymbolUsage::AnnotationAssigned => {
flags.insert(SymbolFlags::ASSIGNED | SymbolFlags::ANNOTATED);
flags.insert(SymbolFlags::DEF_LOCAL | SymbolFlags::ANNOTATED);
}
SymbolUsage::Assigned => {
flags.insert(SymbolFlags::ASSIGNED);
flags.insert(SymbolFlags::DEF_LOCAL);
}
SymbolUsage::AssignedNamedExprInComprehension => {
flags.insert(SymbolFlags::ASSIGNED | SymbolFlags::ASSIGNED_IN_COMPREHENSION);
flags.insert(SymbolFlags::DEF_LOCAL | SymbolFlags::ASSIGNED_IN_COMPREHENSION);
}
SymbolUsage::Global => {
symbol.scope = SymbolScope::GlobalExplicit;
Expand All @@ -3408,7 +3408,7 @@ impl SymbolTableBuilder {
flags.insert(SymbolFlags::ITER | SymbolFlags::COMP_ITER);
}
SymbolUsage::TypeParam => {
flags.insert(SymbolFlags::ASSIGNED | SymbolFlags::TYPE_PARAM);
flags.insert(SymbolFlags::DEF_LOCAL | SymbolFlags::TYPE_PARAM);
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/vm/src/stdlib/_symtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ mod _symtable {

#[pymethod]
const fn is_assigned(&self) -> bool {
self.symbol.flags.contains(SymbolFlags::ASSIGNED)
self.symbol.flags.contains(SymbolFlags::DEF_LOCAL)
}

#[pymethod]
Expand Down