diff --git a/src/state.rs b/src/state.rs index 3132012..4a40e19 100644 --- a/src/state.rs +++ b/src/state.rs @@ -444,6 +444,9 @@ impl <'a> State <'a> { *self.reg_mut (*a) = (b % c).into (); }, Instruction::Move (a, b) => { + // If the value in b is deleted instead of duplicated, + // a bunch of tests fail + *self.reg_mut (*a) = self.reg (*b).clone (); }, Instruction::Mul (a, b, c) => { @@ -474,9 +477,10 @@ impl <'a> State <'a> { let popped_frame = self.stack.pop ().unwrap (); - // Build closure if needed - if *k { - + // Build closure if needed. No point building if we're + // popping the last frame and exiting the program. + + if *k && ! self.stack.is_empty () { let closure_idx = match &self.registers [popped_frame.register_offset + a] { Value::BogusClosure (rc) => rc.borrow ().idx, _ => panic! ("Impossible"), diff --git a/src/value.rs b/src/value.rs index c0ff740..7e8fdae 100644 --- a/src/value.rs +++ b/src/value.rs @@ -45,7 +45,7 @@ impl fmt::Debug for Value { Value::Float (x) => write! (f, "{:?}", x), Value::Integer (x) => write! (f, "{}", x), Value::RsFunc (x) => write! (f, "function: {:?}", x), - Value::String (s) => write! (f, "{}", s), + Value::String (s) => write! (f, "\"{}\"", s), Value::Table (t) => write! (f, "{:?}", t.borrow ()), Value::BogusClosure (x) => write! (f, "{:?}", x.borrow ()), diff --git a/test_vectors/fma.lua b/test_vectors/fma.lua index 9006a99..74c8d22 100644 --- a/test_vectors/fma.lua +++ b/test_vectors/fma.lua @@ -17,9 +17,10 @@ end local function run () local hh = fma (10, 11, 12) print (hh) + return hh end -run () +local hh = run () print (ii) return hh