Skip to content

Commit 870f1bb

Browse files
committed
popblock debug
1 parent a349b9b commit 870f1bb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

vm/src/frame.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,8 +1911,18 @@ impl ExecutingFrame<'_> {
19111911
});
19121912
}
19131913

1914+
#[track_caller]
19141915
fn pop_block(&mut self) -> Block {
19151916
let block = self.state.blocks.pop().expect("No more blocks to pop!");
1917+
#[cfg(debug_assertions)]
1918+
if self.state.stack.len() < block.level {
1919+
dbg!(&self);
1920+
panic!(
1921+
"stack size reversion: current size({}) < truncates target({}).",
1922+
self.state.stack.len(),
1923+
block.level
1924+
);
1925+
}
19161926
self.state.stack.truncate(block.level);
19171927
block
19181928
}
@@ -1945,7 +1955,7 @@ impl ExecutingFrame<'_> {
19451955
}
19461956

19471957
#[inline]
1948-
#[track_caller] // not a real track_caller but pop_value is not very useful
1958+
#[track_caller] // not a real track_caller but top_value is not very useful
19491959
fn top_value(&self) -> &PyObject {
19501960
match &*self.state.stack {
19511961
[.., last] => last,

0 commit comments

Comments
 (0)