mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
feat: Else blocks in definitions
- ensure both run-to-completion and suspendable rule execution stop evaluating bodies once one succeeds so later else branches are skipped - test cases Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
@@ -96,6 +96,10 @@ impl RegoVM {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Once a body in this definition succeeds, remaining bodies
|
||||
// are treated as else-branches and must not be evaluated.
|
||||
break;
|
||||
}
|
||||
Err(_e) => {
|
||||
continue;
|
||||
@@ -502,7 +506,14 @@ impl RegoVM {
|
||||
}
|
||||
}
|
||||
|
||||
frame_data.current_body_index += 1;
|
||||
if let Some(definition_bodies) = rule_info
|
||||
.definitions
|
||||
.get(frame_data.current_definition_index)
|
||||
{
|
||||
frame_data.current_body_index = definition_bodies.len();
|
||||
} else {
|
||||
frame_data.current_body_index += 1;
|
||||
}
|
||||
self.rule_frame_schedule_segment(frame_data, rule_info)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user