Skip to content

Commit

Permalink
core/exec: Correctly pop loops when CONTINUE_OP is called
Browse files Browse the repository at this point in the history
This fixes an issue where a Continue would not pop the actual loop itself,
which would manifest in weird execution flow.

Fixes #141
  • Loading branch information
ElectrodeYT committed Dec 13, 2023
1 parent a228465 commit 604042e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 604042e

Please sign in to comment.