Fix bug with op-assignment.

This commit is contained in:
Stephen Chung 2021-02-24 16:17:04 +08:00
parent 9d6ad2092c
commit 37540fda12
2 changed files with 5 additions and 4 deletions

View File

@ -126,7 +126,7 @@ fn bench_eval_loop_number(bench: &mut Bencher) {
#[bench] #[bench]
fn bench_eval_loop_strings_build(bench: &mut Bencher) { fn bench_eval_loop_strings_build(bench: &mut Bencher) {
let script = r#" let script = r#"
let s = 0; let s = "hello";
for x in range(0, 10000) { for x in range(0, 10000) {
s += "x"; s += "x";
} }

View File

@ -1967,11 +1967,12 @@ impl Engine {
{ {
// Expand to `var = var op rhs` // Expand to `var = var op rhs`
let op = &op[..op.len() - 1]; // extract operator without = 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 // Run function
let (value, _) = self.call_native_fn( let (value, _) = self
mods, state, lib, op, hash_fn, args, false, false, op_pos, .call_native_fn(mods, state, lib, op, hash_fn, args, true, false, op_pos)?;
)?;
*args[0] = value.flatten(); *args[0] = value.flatten();
} }