Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/func/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#[cfg(not(feature = "no_float"))]
#[cfg(feature = "no_std")]
use num_traits::Float;

Check warning on line 33 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / NoStdBuild (ubuntu-latest, --profile unix, false)

unused import: `num_traits::Float`

Check warning on line 33 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / NoStdBuild (macos-latest, --profile macos, false)

unused import: `num_traits::Float`

Check warning on line 33 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / NoStdBuild (windows-latest, --profile windows, true)

unused import: `num_traits::Float`

/// Arguments to a function call, which is a list of [`&mut Dynamic`][Dynamic].
pub type FnCallArgs<'a> = [&'a mut Dynamic];
Expand Down Expand Up @@ -587,8 +587,8 @@
/// functions but provided by Rhai.
pub(crate) fn exec_syntactic_fn_call(
&self,
global: &mut GlobalRuntimeState,

Check warning on line 590 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --tests --features testing-environ,no_float,only_i32,no_object,no_index,no_...

unused variable: `global`

Check warning on line 590 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_function,serde,metadata,internals,debugging,g...

unused variable: `global`

Check warning on line 590 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,no_time,no_function,no_float,no_position,no...

unused variable: `global`

Check warning on line 590 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_time,no_function,no_float,no_position,no_inde...

unused variable: `global`
caches: &mut Caches,

Check warning on line 591 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --tests --features testing-environ,no_float,only_i32,no_object,no_index,no_...

unused variable: `caches`

Check warning on line 591 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_function,serde,metadata,internals,debugging,g...

unused variable: `caches`

Check warning on line 591 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,no_time,no_function,no_float,no_position,no...

unused variable: `caches`

Check warning on line 591 in src/func/call.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_time,no_function,no_float,no_position,no_inde...

unused variable: `caches`
fn_name: &str,
args: &FnCallArgs,
pos: Position,
Expand Down Expand Up @@ -1201,7 +1201,7 @@
first_arg: Option<&Expr>,
args_expr: &[Expr],
hashes: FnCallHashes,
capture_scope: bool,
capture_parent_scope: bool,
pos: Position,
) -> RhaiResult {
let mut first_arg = first_arg;
Expand Down Expand Up @@ -1430,7 +1430,7 @@
//
// If so, do it separately because we cannot convert the first argument (if it is a simple
// variable access) to &mut because `scope` is needed.
if capture_scope && !scope.is_empty() {
if capture_parent_scope && !scope.is_empty() {
for expr in first_arg.iter().copied().chain(args_expr.iter()) {
let (value, ..) =
self.get_arg_value(global, caches, scope, this_ptr.as_deref_mut(), expr)?;
Expand Down
30 changes: 8 additions & 22 deletions src/grain/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,38 +1932,24 @@

/// Whether a call can go through generic dispatch.
///
/// Rhai resolves a handful of names syntactically in `eval_fn_call_expr`
/// before dispatch ever happens (`func/call.rs:1109-1340`), so routing
/// those through `call_fn_raw` would change what they mean. A call that
/// captures the enclosing scope is closure construction, and a qualified
/// name resolves against imported modules; neither is a plain call.
/// Rhai resolves a handful of names syntactically before dispatch ever happens,
/// so routing those through `call_fn_raw` would change what they mean.
/// A call that captures the enclosing scope is closure construction,
/// and a qualified name resolves against imported modules;
/// neither is a plain call.
fn is_lowerable_call(&self, call: &FnCallExpr) -> bool {
// These are handled by `is_syntactic_call` above, but only at the
// arities Rhai treats syntactically — at any other arity it falls
// through to ordinary dispatch, and so must catch them here.
const SYNTACTIC: &[&str] = &[
crate::engine::KEYWORD_EVAL,
crate::engine::KEYWORD_IS_DEF_VAR,
#[cfg(not(feature = "no_function"))]
crate::engine::KEYWORD_IS_DEF_FN,
];

// `is_shared` belongs here for a sharper reason than the rest: Rhai
// answers it syntactically in both call positions (`func/call.rs:1240`
// and `:929`) and registers no function for it anywhere, so a lowered
// call raises `ErrorFunctionNotFound` where the walker returns a bool.
const FN_CALL: &[&str] = &[
crate::engine::KEYWORD_FN_PTR,
crate::engine::KEYWORD_FN_PTR_CALL,
crate::engine::KEYWORD_FN_PTR_CURRY,
#[cfg(not(feature = "no_closure"))]
crate::engine::KEYWORD_IS_SHARED,
];

// These are handled by `fn_ptr_call` above, but only at the arities
// Rhai treats syntactically — at any other arity it falls through to
// ordinary dispatch, and so must this.
if FN_CALL.contains(&call.name.as_str()) {
return false;
}

!call_has_namespace!(call)
&& call.args.len() <= u8::MAX as usize
&& !SYNTACTIC.contains(&call.name.as_str())
Expand Down Expand Up @@ -2398,7 +2384,7 @@
#[cfg(not(feature = "no_function"))]
mod tests {
use super::*;
use crate::grain::bytecode::StepFlags;

Check warning on line 2387 in src/grain/compile/mod.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_object,serde,metadata,internals,debugging,gra...

unused import: `crate::grain::bytecode::StepFlags`

/// Lowering order fixes every address inside a function, so it has to come
/// from the source rather than from a hash map.
Expand Down
Loading
Loading