Skip to content

Commit bd17c08

Browse files
gh-36: CONTINUE errors on failure.
1 parent 6114379 commit bd17c08

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/interpreter.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,6 +2137,11 @@ static ExecResult exec_stmt(Interpreter* interp, Stmt* stmt, Env* env, LabelMap*
21372137
}
21382138

21392139
case STMT_CONTINUE: {
2140+
// CONTINUE is only valid inside a loop
2141+
if (interp->loop_depth == 0) {
2142+
return make_error("CONTINUE used outside loop", stmt->line, stmt->column);
2143+
}
2144+
21402145
ExecResult res;
21412146
res.status = EXEC_CONTINUE;
21422147
res.value = value_null();

0 commit comments

Comments
 (0)