From 37540fda1241a58dc1a2cc274d215fadb030ef84 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 24 Feb 2021 16:17:04 +0800 Subject: [PATCH] Fix bug with op-assignment. --- benches/eval_expression.rs | 2 +- src/engine.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/benches/eval_expression.rs b/benches/eval_expression.rs index ffb0108c..db7a6528 100644 --- a/benches/eval_expression.rs +++ b/benches/eval_expression.rs @@ -126,7 +126,7 @@ fn bench_eval_loop_number(bench: &mut Bencher) { #[bench] fn bench_eval_loop_strings_build(bench: &mut Bencher) { let script = r#" - let s = 0; + let s = "hello"; for x in range(0, 10000) { s += "x"; } diff --git a/src/engine.rs b/src/engine.rs index 1dec6e27..1cafc84b 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -1967,11 +1967,12 @@ impl Engine { { // Expand to `var = var op rhs` let op = &op[..op.len() - 1]; // extract operator without = + let hash_fn = + calc_native_fn_hash(empty(), op, args.iter().map(|a| a.type_id())).unwrap(); // Run function - let (value, _) = self.call_native_fn( - mods, state, lib, op, hash_fn, args, false, false, op_pos, - )?; + let (value, _) = self + .call_native_fn(mods, state, lib, op, hash_fn, args, true, false, op_pos)?; *args[0] = value.flatten(); }