From 7c217dd26472c88b25b337b903c0ac4b33a46e79 Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Thu, 22 Jun 2023 18:13:01 +1000 Subject: [PATCH] Fix copying on method calls --- inputs/{failing => passing}/copyCounting/methodCall.ts | 3 +-- valuescript_vm/src/bytecode_stack_frame.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) rename inputs/{failing => passing}/copyCounting/methodCall.ts (90%) diff --git a/inputs/failing/copyCounting/methodCall.ts b/inputs/passing/copyCounting/methodCall.ts similarity index 90% rename from inputs/failing/copyCounting/methodCall.ts rename to inputs/passing/copyCounting/methodCall.ts index 16155af..9651034 100644 --- a/inputs/failing/copyCounting/methodCall.ts +++ b/inputs/passing/copyCounting/methodCall.ts @@ -1,5 +1,4 @@ -//! test_output(1) -// Should be: 0 +//! test_output(0) /// diff --git a/valuescript_vm/src/bytecode_stack_frame.rs b/valuescript_vm/src/bytecode_stack_frame.rs index 0c5c3ab..c81b7ae 100644 --- a/valuescript_vm/src/bytecode_stack_frame.rs +++ b/valuescript_vm/src/bytecode_stack_frame.rs @@ -357,7 +357,7 @@ impl StackFrameTrait for BytecodeStackFrame { new_frame.write_this( const_call, match &obj { - ThisArg::Register(reg_i) => self.registers[reg_i.clone()].clone(), + ThisArg::Register(reg_i) => take(&mut self.registers[reg_i.clone()]), ThisArg::Val(val) => val.clone(), }, )?;