diff --git a/dust-lang/src/parser.rs b/dust-lang/src/parser.rs index 2990b18..1b86c34 100644 --- a/dust-lang/src/parser.rs +++ b/dust-lang/src/parser.rs @@ -695,9 +695,10 @@ impl<'src> Parser<'src> { self.emit_instruction(previous_instruction, previous_position); self.emit_instruction( - Instruction::set_local(previous_instruction.a(), local_index), + Instruction::set_local(self.current_register, local_index), start_position, ); + self.increment_register()?; self.parsed_expression = false; } else { diff --git a/dust-lang/tests/expressions.rs b/dust-lang/tests/expressions.rs index f04868e..5632359 100644 --- a/dust-lang/tests/expressions.rs +++ b/dust-lang/tests/expressions.rs @@ -818,7 +818,7 @@ fn set_local() { (Instruction::define_local(0, 0, true), Span(8, 9)), (Instruction::load_constant(1, 1, false), Span(20, 22)), (Instruction::set_local(1, 0), Span(16, 17)), - (Instruction::get_local(1, 0), Span(24, 25)), + (Instruction::get_local(2, 0), Span(24, 25)), (Instruction::r#return(true), Span(25, 25)), ], vec![Value::integer(41), Value::integer(42)],