Fix bug in print and println builtins

They were looking at the first item on the stack, rather than the last
item on the stack, for their `to_repr` value.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-09-30 16:28:52 -07:00
parent 43183d6553
commit 8be3586e42

View File

@@ -49,7 +49,7 @@ pub(crate) fn println(vm: &mut Vm, state: FunctionState) -> FunctionResult {
FunctionResult::Yield(0) FunctionResult::Yield(0)
} }
FunctionState::Resume(0) => { FunctionState::Resume(0) => {
println!("{}", vm.frame_stack()[0].borrow()); println!("{}", vm.frame_stack().last().unwrap().borrow());
Nil::create().into() Nil::create().into()
} }
_ => unreachable!(), _ => unreachable!(),
@@ -69,7 +69,7 @@ pub(crate) fn print(vm: &mut Vm, state: FunctionState) -> FunctionResult {
FunctionResult::Yield(0) FunctionResult::Yield(0)
} }
FunctionState::Resume(0) => { FunctionState::Resume(0) => {
print!("{}", vm.frame_stack()[0].borrow()); print!("{}", vm.frame_stack().last().unwrap().borrow());
Nil::create().into() Nil::create().into()
} }
_ => unreachable!(), _ => unreachable!(),