Fix tests.

This commit is contained in:
Stephen Chung
2022-10-27 22:08:47 +08:00
parent 4100645512
commit 25fde7dbed
5 changed files with 21 additions and 6 deletions

View File

@@ -239,6 +239,17 @@ impl<'a> Target<'a> {
_ => None,
}
}
/// Convert a shared or reference [`Target`] into a target with an owned value.
#[inline(always)]
#[must_use]
pub fn into_owned(self) -> Self {
match self {
Self::RefMut(r) => Self::TempValue(r.clone()),
#[cfg(not(feature = "no_closure"))]
Self::SharedValue { value, .. } => Self::TempValue(value),
_ => self,
}
}
/// Get the source [`Dynamic`] of the [`Target`].
#[allow(dead_code)]
#[inline]

View File

@@ -1234,9 +1234,13 @@ impl Engine {
.map(|(value, ..)| arg_values.push(value.flatten()))
})?;
let (target, _pos) =
let (mut target, _pos) =
self.search_namespace(scope, global, lib, this_ptr, first_expr, level)?;
if target.is_read_only() {
target = target.into_owned();
}
self.track_operation(global, _pos)?;
#[cfg(not(feature = "no_closure"))]