From 8be3586e42d7362b0b9e89a9539d0ba3a03539fc Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Mon, 30 Sep 2024 16:28:52 -0700 Subject: [PATCH] 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 --- src/builtins.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builtins.rs b/src/builtins.rs index da58c5e..f28ebf7 100644 --- a/src/builtins.rs +++ b/src/builtins.rs @@ -49,7 +49,7 @@ pub(crate) fn println(vm: &mut Vm, state: FunctionState) -> FunctionResult { FunctionResult::Yield(0) } FunctionState::Resume(0) => { - println!("{}", vm.frame_stack()[0].borrow()); + println!("{}", vm.frame_stack().last().unwrap().borrow()); Nil::create().into() } _ => unreachable!(), @@ -69,7 +69,7 @@ pub(crate) fn print(vm: &mut Vm, state: FunctionState) -> FunctionResult { FunctionResult::Yield(0) } FunctionState::Resume(0) => { - print!("{}", vm.frame_stack()[0].borrow()); + print!("{}", vm.frame_stack().last().unwrap().borrow()); Nil::create().into() } _ => unreachable!(),