🐛 bug: fma test passes with a hack

So closures are kinda working, but I'm probably missing some edge cases.
main
_ 2023-09-29 17:44:54 -05:00
parent 2a0e02aec4
commit 57486f7a65
3 changed files with 10 additions and 5 deletions

View File

@ -444,6 +444,9 @@ impl <'a> State <'a> {
*self.reg_mut (*a) = (b % c).into (); *self.reg_mut (*a) = (b % c).into ();
}, },
Instruction::Move (a, b) => { 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 (); *self.reg_mut (*a) = self.reg (*b).clone ();
}, },
Instruction::Mul (a, b, c) => { Instruction::Mul (a, b, c) => {
@ -474,9 +477,10 @@ impl <'a> State <'a> {
let popped_frame = self.stack.pop ().unwrap (); let popped_frame = self.stack.pop ().unwrap ();
// Build closure if needed // Build closure if needed. No point building if we're
if *k { // 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] { let closure_idx = match &self.registers [popped_frame.register_offset + a] {
Value::BogusClosure (rc) => rc.borrow ().idx, Value::BogusClosure (rc) => rc.borrow ().idx,
_ => panic! ("Impossible"), _ => panic! ("Impossible"),

View File

@ -45,7 +45,7 @@ impl fmt::Debug for Value {
Value::Float (x) => write! (f, "{:?}", x), Value::Float (x) => write! (f, "{:?}", x),
Value::Integer (x) => write! (f, "{}", x), Value::Integer (x) => write! (f, "{}", x),
Value::RsFunc (x) => write! (f, "function: {:?}", 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::Table (t) => write! (f, "{:?}", t.borrow ()),
Value::BogusClosure (x) => write! (f, "{:?}", x.borrow ()), Value::BogusClosure (x) => write! (f, "{:?}", x.borrow ()),

View File

@ -17,9 +17,10 @@ end
local function run () local function run ()
local hh = fma (10, 11, 12) local hh = fma (10, 11, 12)
print (hh) print (hh)
return hh
end end
run () local hh = run ()
print (ii) print (ii)
return hh return hh