mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 21:55:26 +00:00
Fix scope_for_name to catch NameError properly
This commit is contained in:
parent
fde382409c
commit
5135c696e7
2 changed files with 5 additions and 5 deletions
|
@ -1877,7 +1877,9 @@ impl<O: OutputStream> Compiler<O> {
|
|||
fn lookup_name(&self, name: &str) -> &Symbol {
|
||||
// println!("Looking up {:?}", name);
|
||||
let scope = self.scope_stack.last().unwrap();
|
||||
scope.lookup(name).unwrap()
|
||||
scope.lookup(name).expect(
|
||||
"The symbol must be present in the symbol table, even when it is undefined in python.",
|
||||
)
|
||||
}
|
||||
|
||||
// Low level helper functions:
|
||||
|
|
|
@ -244,13 +244,11 @@ impl SymbolTableBuilder {
|
|||
} => {
|
||||
self.scan_expressions(decorator_list)?;
|
||||
self.register_name(name, SymbolRole::Assigned)?;
|
||||
|
||||
self.enter_function(args)?;
|
||||
|
||||
self.scan_statements(body)?;
|
||||
if let Some(expression) = returns {
|
||||
self.scan_expression(expression)?;
|
||||
}
|
||||
self.enter_function(args)?;
|
||||
self.scan_statements(body)?;
|
||||
self.leave_scope();
|
||||
}
|
||||
ClassDef {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue