diff --git a/compiler/codegen/src/compile.rs b/compiler/codegen/src/compile.rs index e5976047a3..0b0f2877c7 100644 --- a/compiler/codegen/src/compile.rs +++ b/compiler/codegen/src/compile.rs @@ -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;