diff --git a/lunar_wave_vm/src/state.rs b/lunar_wave_vm/src/state.rs index 0b7d176..5a5d9d0 100644 --- a/lunar_wave_vm/src/state.rs +++ b/lunar_wave_vm/src/state.rs @@ -468,14 +468,6 @@ impl State { let block = self.chunk.blocks.get (frame.block_idx).unwrap (); let constants = &block.constants; - let value = if k { - &constants [usize::from (c)] - } - else { - self.reg (c) - } - .clone (); - let b = usize::try_from (b).unwrap (); let key = match constants.get (b).unwrap () { @@ -483,6 +475,13 @@ impl State { _ => panic! ("SetField only supports string keys"), }; + let value = if k { + &constants [usize::from (c)] + } + else { + self.reg_mut (c) + }.clone (); + let mut dst = self.reg (a).as_table () .expect ("SetField only works on tables").borrow_mut (); @@ -506,12 +505,8 @@ impl State { pub fn step (&mut self) -> Result