Dump the stack when the lua guard fails and return a value from it

This commit is contained in:
William Venner 2022-01-04 21:57:27 +00:00
parent 5facacaf20
commit d37db94360
1 changed files with 6 additions and 2 deletions

View File

@ -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))]