Fix no_function build.

This commit is contained in:
Stephen Chung 2020-10-05 12:09:45 +08:00
parent 4356d02828
commit 29bf790286
2 changed files with 5 additions and 2 deletions

View File

@ -295,6 +295,7 @@ impl Module {
}
/// Get a script-defined function in the module based on name and number of parameters.
#[cfg(not(feature = "no_function"))]
pub fn get_script_fn(
&self,
name: &str,

View File

@ -605,8 +605,10 @@ fn optimize_expr(expr: Expr, state: &mut State) -> Expr {
let ((name, _, _, pos), _, _, args, def_value) = x.as_mut();
// First search for script-defined functions (can override built-in)
let has_script_fn = cfg!(not(feature = "no_function"))
&& state.lib.get_script_fn(name, args.len(), false).is_some();
#[cfg(not(feature = "no_function"))]
let has_script_fn = state.lib.get_script_fn(name, args.len(), false).is_some();
#[cfg(feature = "no_function")]
let has_script_fn = false;
if !has_script_fn {
let mut arg_values: StaticVec<_> = args.iter().map(Expr::get_constant_value).collect();