mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
Check variables in scope in DeleteFast
This commit is contained in:
1 parent
7a6000d181
commit
f4b54082cf
1 file changed
+9
-1
+9
-1
@@ -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) => {
|
||||
|
||||
Reference in new issue
Block a user