Skip to content

Commit 03eb2dd

Browse files
committed
Fix LoadNameAny opecode
1 parent b1db1be commit 03eb2dd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

vm/src/frame.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,14 @@ impl ExecutingFrame<'_> {
538538
}
539539
bytecode::Instruction::LoadNameAny(idx) => {
540540
let name = self.code.names[*idx as usize];
541-
let value = self.locals.mapping().subscript(name, vm).ok();
542-
self.push_value(match value {
543-
Some(x) => x,
544-
None => self.load_global_or_builtin(name, vm)?,
545-
});
541+
let result = self.locals.mapping().subscript(name, vm);
542+
match result {
543+
Ok(x) => self.push_value(x),
544+
Err(e) if e.class().is(vm.ctx.exceptions.key_error) => {
545+
self.push_value(self.load_global_or_builtin(name, vm)?);
546+
}
547+
Err(e) => return Err(e),
548+
}
546549
Ok(None)
547550
}
548551
bytecode::Instruction::LoadGlobal(idx) => {

0 commit comments

Comments
 (0)