Fix LoadNameAny opecode

This commit is contained in:
yt2b
2022-12-28 22:14:22 +09:00
parent b1db1be031
commit 03eb2dd11b

View File

@@ -538,11 +538,14 @@ impl ExecutingFrame<'_> {
}
bytecode::Instruction::LoadNameAny(idx) => {
let name = self.code.names[*idx as usize];
let value = self.locals.mapping().subscript(name, vm).ok();
self.push_value(match value {
Some(x) => x,
None => self.load_global_or_builtin(name, vm)?,
});
let result = self.locals.mapping().subscript(name, vm);
match result {
Ok(x) => self.push_value(x),
Err(e) if e.class().is(vm.ctx.exceptions.key_error) => {
self.push_value(self.load_global_or_builtin(name, vm)?);
}
Err(e) => return Err(e),
}
Ok(None)
}
bytecode::Instruction::LoadGlobal(idx) => {