From 604042e7db71f3d990256ca211cd8c83964890f3 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 13 Dec 2023 17:34:34 +0100 Subject: [PATCH] core/exec: Correctly pop loops when CONTINUE_OP is called This fixes an issue where a Continue would not pop the actual loop itself, which would manifest in weird execution flow. Fixes #141 --- core/exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/exec.c b/core/exec.c index f7953d9..616adc9 100644 --- a/core/exec.c +++ b/core/exec.c @@ -2408,8 +2408,8 @@ static lai_api_error_t lai_exec_parse(int parse_mode, lai_state_t *state) { lai_exec_pop_stack_back(state); } - // Keep the LAI_LOOP_STACKITEM but reset the PC. - pc = loop_item->loop_pred; + // Set the PC of the block to its limit, to trigger a recheck of the predicate. + lai_exec_peek_blkstack_back(state)->pc = lai_exec_peek_blkstack_back(state)->limit; break; } /* Break Loop */