From d37db94360999f47a72ded901646c898327221db Mon Sep 17 00:00:00 2001 From: William Venner Date: Tue, 4 Jan 2022 21:57:27 +0000 Subject: [PATCH] Dump the stack when the lua guard fails and return a value from it --- gmod/src/lua/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gmod/src/lua/mod.rs b/gmod/src/lua/mod.rs index 9656111..a359a66 100644 --- a/gmod/src/lua/mod.rs +++ b/gmod/src/lua/mod.rs @@ -70,8 +70,12 @@ macro_rules! lua_stack_guard { ( $lua:ident => $code:block ) => {{ #[cfg(debug_assertions)] { let top = $lua.get_top(); - $code - assert_eq!(top, $lua.get_top(), "Stack is dirty!"); + let ret = (|| $code)(); + if top != $lua.get_top() { + $lua.dump_stack(); + panic!("Stack is dirty!"); + } + ret } #[cfg(not(debug_assertions))]