mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user