mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-19 19:15:43 +00:00
Try to use loadname local replace loadname free
This commit is contained in:
parent
f6e25fc0cb
commit
5ca3fc79f4
2 changed files with 5 additions and 3 deletions
|
@ -298,7 +298,7 @@ impl<O: OutputStream> Compiler<O> {
|
|||
SymbolScope::Global => bytecode::NameScope::Global,
|
||||
SymbolScope::Nonlocal => bytecode::NameScope::NonLocal,
|
||||
SymbolScope::Unknown => bytecode::NameScope::Free,
|
||||
SymbolScope::Local => bytecode::NameScope::Free,
|
||||
SymbolScope::Local => bytecode::NameScope::Local,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -276,6 +276,8 @@ impl<'a> SymbolTableAnalyzer<'a> {
|
|||
fn analyze_unknown_symbol(&self, symbol: &mut Symbol) {
|
||||
if symbol.is_assigned || symbol.is_parameter {
|
||||
symbol.scope = SymbolScope::Local;
|
||||
} else if symbol.is_referenced {
|
||||
symbol.scope = SymbolScope::Unknown;
|
||||
} else {
|
||||
// Interesting stuff about the __class__ variable:
|
||||
// https://docs.python.org/3/reference/datamodel.html?highlight=__class__#creating-the-class-object
|
||||
|
@ -680,11 +682,11 @@ impl SymbolTableBuilder {
|
|||
self.scan_expressions(vals, context)?;
|
||||
}
|
||||
Subscript { a, b } => {
|
||||
self.scan_expression(a, context)?;
|
||||
self.scan_expression(a, &ExpressionContext::Load)?;
|
||||
self.scan_expression(b, context)?;
|
||||
}
|
||||
Attribute { value, .. } => {
|
||||
self.scan_expression(value, context)?;
|
||||
self.scan_expression(value, &ExpressionContext::Load)?;
|
||||
}
|
||||
Dict { elements } => {
|
||||
for (key, value) in elements {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue