Early return for 'some in' statement (#427)

* fix: use early exit in 'some in' statements

Update kata tests:
Since 'early return' now works with 'some in' statement, interpreter
does not do any evaluation after it found match for rule, therefore
we don't have other rule checks after interpreter found match
This commit is contained in:
Kirill Zabelin
2025-07-08 20:47:06 +02:00
committed by GitHub
parent 0a9864f3ec
commit a29bfeeb4f
13 changed files with 33 additions and 801 deletions

View File

@@ -1017,6 +1017,11 @@ impl Interpreter {
if self.eval_stmts(stmts)? {
count += 1;
if let Some(ctx) = self.contexts.last() {
if ctx.early_return {
break;
}
}
}
*self.current_scope_mut()? = scope_saved.clone();
}
@@ -1035,6 +1040,11 @@ impl Interpreter {
if self.eval_stmts(stmts)? {
count += 1;
if let Some(ctx) = self.contexts.last() {
if ctx.early_return {
break;
}
}
}
*self.current_scope_mut()? = scope_saved.clone();
}
@@ -1054,6 +1064,11 @@ impl Interpreter {
if self.eval_stmts(stmts)? {
count += 1;
if let Some(ctx) = self.contexts.last() {
if ctx.early_return {
break;
}
}
}
*self.current_scope_mut()? = scope_saved.clone();
}