From 89f9b31c2b7278da5c79e893ce9955093e8977ad Mon Sep 17 00:00:00 2001 From: Artemy Date: Mon, 15 Aug 2022 17:23:28 +0300 Subject: [PATCH] fix: compilation of the panic hook only on release --- examples/example.json5 | 3 ++- src/main.rs | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/example.json5 b/examples/example.json5 index 6a90f8f..d2f3783 100644 --- a/examples/example.json5 +++ b/examples/example.json5 @@ -290,9 +290,10 @@ }, }, + "fn sum(first, second){ return first+second};", "Run function `sum`", - ["fn sum(first, second){ return first+second}; sum(2,2) = ", { sum: [2, 2] }], + ["sum(2, 2) = ", { sum: [2, 2] }], "\nInput a var", { diff --git a/src/main.rs b/src/main.rs index e134adb..b746f52 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,15 +15,16 @@ mod interpreter; use interpreter::Interpreter; fn main() { - // std::panic::set_hook(Box::new(|info| { - // eprint!( - // "{msg}", - // msg = match info.payload().downcast_ref::() { - // None => "Program panicked without a message!", - // Some(x) => x, - // } - // ); - // })); + #[cfg(not(debug_assertions))] + std::panic::set_hook(Box::new(|info| { + eprint!( + "{msg}", + msg = match info.payload().downcast_ref::() { + None => "Program panicked without a message!", + Some(x) => x, + } + ); + })); let start = Instant::now(); let args = Args::parse();