Skip to content

Commit 289172a

Browse files
committed
Fix StoreFastStoreFast to handle NULL from LoadFastAndClear
StoreFast uses pop_value_opt() to allow NULL values from LoadFastAndClear in inlined comprehension cleanup paths. StoreFastStoreFast must do the same, otherwise the peephole optimizer's fusion of two StoreFast instructions panics when restoring unbound locals after an inlined comprehension.
1 parent ce07e05 commit 289172a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/vm/src/frame.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,11 +3446,12 @@ impl ExecutingFrame<'_> {
34463446
Instruction::StoreFastStoreFast { var_nums } => {
34473447
let oparg = var_nums.get(arg);
34483448
let (idx1, idx2) = oparg.indexes();
3449-
let value1 = self.pop_value();
3450-
let value2 = self.pop_value();
3449+
// pop_value_opt: allows NULL from LoadFastAndClear restore path
3450+
let value1 = self.pop_value_opt();
3451+
let value2 = self.pop_value_opt();
34513452
let fastlocals = self.localsplus.fastlocals_mut();
3452-
fastlocals[idx1] = Some(value1);
3453-
fastlocals[idx2] = Some(value2);
3453+
fastlocals[idx1] = value1;
3454+
fastlocals[idx2] = value2;
34543455
Ok(None)
34553456
}
34563457
Instruction::StoreGlobal { namei: idx } => {

0 commit comments

Comments
 (0)