diff --git a/src/engine.rs b/src/engine.rs index a852b3fa..b7b73f2a 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -639,9 +639,7 @@ impl Engine { ) .or_else(|err| match *err { // If there is no index setter, no need to set it back because the indexer is read-only - EvalAltResult::ErrorFunctionNotFound(s, _) - if s == FN_IDX_SET => - { + EvalAltResult::ErrorFunctionNotFound(_, _) => { Ok(Default::default()) } _ => Err(err), diff --git a/src/fn_call.rs b/src/fn_call.rs index 616fe2f6..98228853 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -864,10 +864,22 @@ impl Engine { EvalAltResult::ErrorFunctionNotFound(_, _) if def_val.is_some() => { Ok(def_val.unwrap().into()) } - EvalAltResult::ErrorFunctionNotFound(_, _) => { + EvalAltResult::ErrorFunctionNotFound(_, pos) => { Err(Box::new(EvalAltResult::ErrorFunctionNotFound( - format!("{}{}", modules, name), - Position::none(), + format!( + "{}{} ({})", + modules, + name, + args.iter() + .map(|a| if a.is::() { + "&str | ImmutableString | String" + } else { + self.map_type_name((*a).type_name()) + }) + .collect::>() + .join(", ") + ), + pos, ))) } _ => Err(err), diff --git a/src/fn_native.rs b/src/fn_native.rs index 2833729a..8fc60714 100644 --- a/src/fn_native.rs +++ b/src/fn_native.rs @@ -9,9 +9,12 @@ use crate::token::{is_valid_identifier, Position}; use crate::utils::{ImmutableString, StaticVec}; use crate::Scope; -use crate::stdlib::{ - boxed::Box, convert::TryFrom, fmt, mem, rc::Rc, string::String, sync::Arc, vec::Vec, -}; +use crate::stdlib::{boxed::Box, convert::TryFrom, fmt, mem, string::String, vec::Vec}; + +#[cfg(not(feature = "sync"))] +use crate::stdlib::rc::Rc; +#[cfg(feature = "sync")] +use crate::stdlib::sync::Arc; /// Trait that maps to `Send + Sync` only under the `sync` feature. #[cfg(feature = "sync")] diff --git a/src/packages/arithmetic.rs b/src/packages/arithmetic.rs index 5e43c05b..3e3852d6 100644 --- a/src/packages/arithmetic.rs +++ b/src/packages/arithmetic.rs @@ -20,9 +20,12 @@ use crate::stdlib::{ boxed::Box, fmt::Display, format, - ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub}, + ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Sub}, }; +#[cfg(feature = "unchecked")] +use crate::stdlib::ops::{Shl, Shr}; + // Checked add pub(crate) fn add(x: T, y: T) -> FuncReturn { x.checked_add(&y).ok_or_else(|| { @@ -171,10 +174,12 @@ pub(crate) fn shr(x: T, y: INT) -> FuncReturn { }) } // Unchecked left-shift - may panic if shifting by a negative number of bits +#[cfg(feature = "unchecked")] pub(crate) fn shl_u>(x: T, y: T) -> FuncReturn<>::Output> { Ok(x.shl(y)) } // Unchecked right-shift - may panic if shifting by a negative number of bits +#[cfg(feature = "unchecked")] pub(crate) fn shr_u>(x: T, y: T) -> FuncReturn<>::Output> { Ok(x.shr(y)) } @@ -229,6 +234,7 @@ pub(crate) fn pow_i_i(x: INT, y: INT) -> FuncReturn { } } // Unchecked integer power - may panic on overflow or if the power index is too high (> u32::MAX) +#[cfg(feature = "unchecked")] pub(crate) fn pow_i_i_u(x: INT, y: INT) -> FuncReturn { Ok(x.pow(y as u32)) } diff --git a/src/packages/mod.rs b/src/packages/mod.rs index 43ae5f28..8207a966 100644 --- a/src/packages/mod.rs +++ b/src/packages/mod.rs @@ -74,6 +74,7 @@ impl PackagesCollection { .flatten() } /// Does the specified TypeId iterator exist in the `PackagesCollection`? + #[allow(dead_code)] pub fn contains_iter(&self, id: TypeId) -> bool { self.0.iter().any(|p| p.contains_iter(id)) } diff --git a/src/packages/time_basic.rs b/src/packages/time_basic.rs index cbf13f1b..7c166ab1 100644 --- a/src/packages/time_basic.rs +++ b/src/packages/time_basic.rs @@ -1,12 +1,17 @@ #![cfg(not(feature = "no_std"))] use super::logic::{eq, gt, gte, lt, lte, ne}; + +#[cfg(feature = "no_float")] use super::math_basic::MAX_INT; use crate::def_package; -use crate::module::FuncReturn; -use crate::parser::INT; use crate::result::EvalAltResult; -use crate::token::Position; + +#[cfg(not(feature = "no_float"))] +use crate::parser::FLOAT; + +#[cfg(feature = "no_float")] +use crate::{module::FuncReturn, parser::INT, token::Position}; #[cfg(not(target_arch = "wasm32"))] use crate::stdlib::time::Instant; @@ -14,9 +19,6 @@ use crate::stdlib::time::Instant; #[cfg(target_arch = "wasm32")] use instant::Instant; -#[cfg(not(feature = "no_float"))] -use crate::parser::FLOAT; - def_package!(crate:BasicTimePackage:"Basic timing utilities.", lib, { // Register date/time functions lib.set_fn_0("timestamp", || Ok(Instant::now())); diff --git a/src/syntax.rs b/src/syntax.rs index 616833c1..9dfc255f 100644 --- a/src/syntax.rs +++ b/src/syntax.rs @@ -14,11 +14,14 @@ use crate::utils::StaticVec; use crate::stdlib::{ boxed::Box, fmt, format, - rc::Rc, string::{String, ToString}, - sync::Arc, }; +#[cfg(not(feature = "sync"))] +use crate::stdlib::rc::Rc; +#[cfg(feature = "sync")] +use crate::stdlib::sync::Arc; + /// A general expression evaluation trait object. #[cfg(not(feature = "sync"))] pub type FnCustomSyntaxEval = dyn Fn(