From d9d976a8853a843b70d04198566e1df464eee894 Mon Sep 17 00:00:00 2001 From: Kai Schmidt Date: Tue, 26 Mar 2024 11:32:30 -0700 Subject: [PATCH] fix a repl crash --- src/compile/binding.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/compile/binding.rs b/src/compile/binding.rs index 4669d39fb..200ae7747 100644 --- a/src/compile/binding.rs +++ b/src/compile/binding.rs @@ -324,10 +324,11 @@ impl Compiler { let val = val.clone(); self.asm.instrs.pop(); self.asm.bind_const(local, Some(val), span_index, comment); - let last_slice = self.asm.top_slices.last_mut().unwrap(); - last_slice.len -= 1; - if last_slice.len == 0 { - self.asm.top_slices.pop(); + if let Some(last_slice) = self.asm.top_slices.last_mut() { + last_slice.len -= 1; + if last_slice.len == 0 { + self.asm.top_slices.pop(); + } } } else { self.asm.bind_const(local, None, span_index, comment);