Use references for switch expressions, if possible.

This commit is contained in:
Stephen Chung
2020-11-14 16:08:48 +08:00
parent 83c7c101d1
commit 56fbe39b7b
4 changed files with 195 additions and 54 deletions

View File

@@ -1042,9 +1042,14 @@ impl Engine {
.map(|expr| self.eval_expr(scope, mods, state, lib, this_ptr, expr, level))
.collect::<Result<_, _>>()?;
let (target, _, _, pos) =
let (target, _, typ, pos) =
self.search_namespace(scope, mods, state, lib, this_ptr, &args_expr[0])?;
let target = match typ {
ScopeEntryType::Normal => target,
ScopeEntryType::Constant => target.into_owned(),
};
self.inc_operations(state)
.map_err(|err| err.fill_position(pos))?;