🐛 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 ();
},
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"),

View File

@ -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 ()),

View File

@ -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