Fix bug on chaining function calls returning shared values.

This commit is contained in:
Stephen Chung
2022-06-07 11:31:46 +08:00
parent 005692ef78
commit 84e3296559
3 changed files with 38 additions and 2 deletions

View File

@@ -652,7 +652,9 @@ impl Engine {
_ if is_assignment => unreachable!("cannot assign to an expression"),
// {expr}.??? or {expr}[???]
expr => {
let value = self.eval_expr(scope, global, caches, lib, this_ptr, expr, level)?;
let value = self
.eval_expr(scope, global, caches, lib, this_ptr, expr, level)?
.flatten();
let obj_ptr = &mut value.into();
let root = ("", expr.start_position());
self.eval_dot_index_chain_helper(
@@ -1043,6 +1045,11 @@ impl Engine {
})
}
#[cfg(not(feature = "no_closure"))]
Dynamic(Union::Shared(..)) => {
unreachable!("`get_indexed_mut` cannot handle shared values")
}
_ if use_indexers => self
.call_indexer_get(global, caches, lib, target, &mut idx, level)
.map(Into::into),