fix: add loop context validation for break/continue statements#44
fix: add loop context validation for break/continue statements#44hyperpolymath merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dab5a79a1c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| } | ||
| } | ||
| self.in_loop_context = false; |
There was a problem hiding this comment.
Preserve outer loop context when exiting nested loops
The new loop-context tracking uses a single boolean and unconditionally writes false when this while finishes, which clobbers an outer loop’s active context. In a nested case like loop { while cond { ... } break; }, the break after the inner while is still inside the outer loop but will now be reported as “outside of loop context.” Please save/restore the previous context (or use a loop-depth counter) instead of forcing false on exit.
Useful? React with 👍 / 👎.
| }; | ||
|
|
||
| let mut result = Value::Unit; | ||
| self.in_loop_context = true; |
There was a problem hiding this comment.
Restore loop context on non-fallthrough loop exits
in_loop_context is set to true before entering the loop, but it is only cleared on the normal fallthrough path; early exits (break, return, or ?-propagated errors) return before cleanup runs. That leaves the interpreter stuck in loop context, so later break/continue statements outside any loop can incorrectly pass validation. This needs guaranteed restoration across all exit paths (e.g., scoped guard or explicit save/restore).
Useful? React with 👍 / 👎.
No description provided.