Check variables in scope in DeleteFast

This commit is contained in:
Patrick He committed 2023-05-19 05:06:15 -04:00
1 parent 7a6000d181
commit f4b54082cf
1 file changed
+9 -1
+9 -1
View File
@@ -607,7 +607,15 @@ impl ExecutingFrame<'_> {
Ok(None)
}
bytecode::Instruction::DeleteFast(idx) => {
self.fastlocals.lock()[idx.get(arg) as usize] = None;
let mut fastlocals = self.fastlocals.lock();
let idx = idx.get(arg) as usize;
if fastlocals[idx].is_none() {
return Err(vm.new_exception_msg(
vm.ctx.exceptions.unbound_local_error.to_owned(),
format!("local variable '{}' referenced before assignment", self.code.varnames[idx]),
));
}
fastlocals[idx] = None;
Ok(None)
}
bytecode::Instruction::DeleteLocal(idx) => {