Skip to content

Commit f4b5408

Browse files
committed
Check variables in scope in DeleteFast
1 parent 7a6000d commit f4b5408

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

vm/src/frame.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,15 @@ impl ExecutingFrame<'_> {
607607
Ok(None)
608608
}
609609
bytecode::Instruction::DeleteFast(idx) => {
610-
self.fastlocals.lock()[idx.get(arg) as usize] = None;
610+
let mut fastlocals = self.fastlocals.lock();
611+
let idx = idx.get(arg) as usize;
612+
if fastlocals[idx].is_none() {
613+
return Err(vm.new_exception_msg(
614+
vm.ctx.exceptions.unbound_local_error.to_owned(),
615+
format!("local variable '{}' referenced before assignment", self.code.varnames[idx]),
616+
));
617+
}
618+
fastlocals[idx] = None;
611619
Ok(None)
612620
}
613621
bytecode::Instruction::DeleteLocal(idx) => {

0 commit comments

Comments
 (0)