From 456e555e8b173cde5ed16f2d784ee56a4601843c Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Tue, 15 Apr 2025 09:25:06 -0700 Subject: [PATCH] better error --- compiler/codegen/src/ir.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/codegen/src/ir.rs b/compiler/codegen/src/ir.rs index 39857e6fc..9106d3fdf 100644 --- a/compiler/codegen/src/ir.rs +++ b/compiler/codegen/src/ir.rs @@ -244,7 +244,8 @@ impl CodeInfo { let instr_display = instr.display(display_arg, self); eprint!("{instr_display}: {depth} {effect:+} => "); } - let new_depth = depth.checked_add_signed(effect).unwrap(); + // Either it's less than 0 or more than u32. Option 1 is far more likely unless something is seriously wrong. + let new_depth = depth.checked_add_signed(effect).expect("The stack is detected to have likely been reduced to less than 0 elements, this is a bug."); if DEBUG { eprintln!("{new_depth}"); }