better symboltable error message

This commit is contained in:
Jeong YunWon
2024-02-29 21:30:31 +09:00
parent e6c6f966f7
commit d26766b7bc

View File

@@ -478,8 +478,8 @@ impl Compiler {
self.check_forbidden_name(&name, usage)?;
let symbol_table = self.symbol_table_stack.last().unwrap();
let symbol = symbol_table.lookup(name.as_ref()).expect(
"The symbol must be present in the symbol table, even when it is undefined in python.",
let symbol = symbol_table.lookup(name.as_ref()).unwrap_or_else(||
panic!("The symbol '{name}' must be present in the symbol table, even when it is undefined in python."),
);
let info = self.code_stack.last_mut().unwrap();
let mut cache = &mut info.name_cache;