From 3b97bcea13da6b21452bce4136ad6e54f28c9348 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Fri, 7 Feb 2025 13:09:07 -0500 Subject: [PATCH] Give context in StackUnderflow --- zjit/src/ir.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zjit/src/ir.rs b/zjit/src/ir.rs index 52454594de..66c9c7a5f0 100644 --- a/zjit/src/ir.rs +++ b/zjit/src/ir.rs @@ -229,11 +229,11 @@ impl FrameState { } fn top(&self) -> Result { - self.stack.last().ok_or(ParseError::StackUnderflow).copied() + self.stack.last().ok_or_else(|| ParseError::StackUnderflow(self.clone())).copied() } fn pop(&mut self) -> Result { - self.stack.pop().ok_or(ParseError::StackUnderflow) + self.stack.pop().ok_or_else(|| ParseError::StackUnderflow(self.clone())) } fn setn(&mut self, n: usize, opnd: Opnd) { @@ -308,7 +308,7 @@ fn compute_jump_targets(iseq: *const rb_iseq_t) -> Vec { #[derive(Debug)] pub enum ParseError { - StackUnderflow, + StackUnderflow(FrameState), } pub fn iseq_to_ssa(iseq: *const rb_iseq_t) -> Result {