From 9f18d6519d598f75fe6b48e54be39c626b26479a Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 12 Feb 2023 00:13:54 +0800 Subject: [PATCH] Use debug_assert!. --- src/ast/expr.rs | 2 +- src/eval/expr.rs | 2 +- src/eval/stmt.rs | 2 +- src/func/call.rs | 4 ++-- src/tokenizer.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ast/expr.rs b/src/ast/expr.rs index 957a195e..586d5815 100644 --- a/src/ast/expr.rs +++ b/src/ast/expr.rs @@ -185,7 +185,7 @@ impl FnCallHashes { #[inline(always)] #[must_use] pub fn script(&self) -> u64 { - assert!(self.script.is_some()); + debug_assert!(self.script.is_some()); self.script.unwrap() } } diff --git a/src/eval/expr.rs b/src/eval/expr.rs index 925a8132..0f3125f4 100644 --- a/src/eval/expr.rs +++ b/src/eval/expr.rs @@ -20,7 +20,7 @@ impl Engine { global: &GlobalRuntimeState, namespace: &crate::ast::Namespace, ) -> Option { - assert!(!namespace.is_empty()); + debug_assert!(!namespace.is_empty()); let root = namespace.root(); diff --git a/src/eval/stmt.rs b/src/eval/stmt.rs index 417049b8..2fac1fe2 100644 --- a/src/eval/stmt.rs +++ b/src/eval/stmt.rs @@ -343,7 +343,7 @@ impl Engine { // First check hashes if let Some(case_blocks_list) = cases.get(&hash) { - assert!(!case_blocks_list.is_empty()); + debug_assert!(!case_blocks_list.is_empty()); for &index in case_blocks_list { let block = &expressions[index]; diff --git a/src/func/call.rs b/src/func/call.rs index bdcdf899..2eb7ace7 100644 --- a/src/func/call.rs +++ b/src/func/call.rs @@ -363,7 +363,7 @@ impl Engine { ); if let Some(FnResolutionCacheEntry { func, source }) = func { - assert!(func.is_native()); + debug_assert!(func.is_native()); // Push a new call stack frame #[cfg(feature = "debugging")] @@ -633,7 +633,7 @@ impl Engine { .cloned() { // Script function call - assert!(func.is_script()); + debug_assert!(func.is_script()); let f = func.get_script_fn_def().expect("script-defined function"); let environ = func.get_encapsulated_environ(); diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 717b7282..4ec35bea 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -932,7 +932,7 @@ pub fn parse_string_literal( } loop { - assert!( + debug_assert!( !verbatim || escape.is_empty(), "verbatim strings should not have any escapes" );