Pass level to var resolver.
This commit is contained in:
parent
5aee06674f
commit
936dc01e39
@ -673,7 +673,7 @@ impl Engine {
|
||||
self.inc_operations(&mut global.num_operations, *var_pos)?;
|
||||
|
||||
let (mut target, _) =
|
||||
self.search_namespace(scope, global, state, lib, this_ptr, lhs)?;
|
||||
self.search_namespace(scope, global, state, lib, this_ptr, lhs, level)?;
|
||||
|
||||
let obj_ptr = &mut target;
|
||||
let root = (x.2.as_str(), *var_pos);
|
||||
|
@ -50,15 +50,18 @@ impl Engine {
|
||||
lib: &[&Module],
|
||||
this_ptr: &'s mut Option<&mut Dynamic>,
|
||||
expr: &Expr,
|
||||
level: usize,
|
||||
) -> RhaiResultOf<(Target<'s>, Position)> {
|
||||
match expr {
|
||||
Expr::Variable(Some(_), _, _) => {
|
||||
self.search_scope_only(scope, global, state, lib, this_ptr, expr)
|
||||
self.search_scope_only(scope, global, state, lib, this_ptr, expr, level)
|
||||
}
|
||||
Expr::Variable(None, _var_pos, v) => match v.as_ref() {
|
||||
// Normal variable access
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
(_, None, _) => self.search_scope_only(scope, global, state, lib, this_ptr, expr),
|
||||
(_, None, _) => {
|
||||
self.search_scope_only(scope, global, state, lib, this_ptr, expr, level)
|
||||
}
|
||||
#[cfg(feature = "no_module")]
|
||||
(_, (), _) => self.search_scope_only(scope, global, state, lib, this_ptr, expr),
|
||||
|
||||
@ -136,6 +139,7 @@ impl Engine {
|
||||
lib: &[&Module],
|
||||
this_ptr: &'s mut Option<&mut Dynamic>,
|
||||
expr: &Expr,
|
||||
level: usize,
|
||||
) -> RhaiResultOf<(Target<'s>, Position)> {
|
||||
// Make sure that the pointer indirection is taken only when absolutely necessary.
|
||||
|
||||
@ -163,7 +167,7 @@ impl Engine {
|
||||
state,
|
||||
lib,
|
||||
this_ptr,
|
||||
level: 0,
|
||||
level,
|
||||
};
|
||||
match resolve_var(
|
||||
expr.get_variable_name(true).expect("`Expr::Variable`"),
|
||||
@ -297,7 +301,7 @@ impl Engine {
|
||||
.cloned()
|
||||
.ok_or_else(|| ERR::ErrorUnboundThis(*var_pos).into())
|
||||
} else {
|
||||
self.search_namespace(scope, global, state, lib, this_ptr, expr)
|
||||
self.search_namespace(scope, global, state, lib, this_ptr, expr, level)
|
||||
.map(|(val, _)| val.take_or_clone())
|
||||
};
|
||||
}
|
||||
|
@ -1230,7 +1230,7 @@ impl Engine {
|
||||
})?;
|
||||
|
||||
let (mut target, _pos) =
|
||||
self.search_namespace(scope, global, state, lib, this_ptr, first_expr)?;
|
||||
self.search_namespace(scope, global, state, lib, this_ptr, first_expr, level)?;
|
||||
|
||||
if target.as_ref().is_read_only() {
|
||||
target = target.into_owned();
|
||||
@ -1316,8 +1316,9 @@ impl Engine {
|
||||
})?;
|
||||
|
||||
// Get target reference to first argument
|
||||
let first_arg = &args_expr[0];
|
||||
let (target, _pos) =
|
||||
self.search_scope_only(scope, global, state, lib, this_ptr, &args_expr[0])?;
|
||||
self.search_scope_only(scope, global, state, lib, this_ptr, first_arg, level)?;
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
self.inc_operations(&mut global.num_operations, _pos)?;
|
||||
|
Loading…
Reference in New Issue
Block a user