mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
early return (#189)
If a rule is written to produce a constant value, then not all iterations of loops
within it need to be executed. Execution can stop via early return once the first iteration
that produces a value has been executed.
This brings forth the question : What if one of the subsequent iterations would have resulted
in an error?
e.g:
x {
[1, "hello"][_] + 1
}
Such errors are not raised; consistent with OPA.
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
de56cce7cb
commit
316f3a7692
@@ -73,10 +73,10 @@ fn match_values(computed: &Value, expected: &Value) -> Result<()> {
|
||||
if computed != expected {
|
||||
panic!(
|
||||
"{}",
|
||||
colored_diff::PrettyDifference {
|
||||
expected: &serde_yaml::to_string(&expected)?,
|
||||
actual: &serde_yaml::to_string(&computed)?
|
||||
}
|
||||
prettydiff::diff_chars(
|
||||
&serde_yaml::to_string(&expected)?,
|
||||
&serde_yaml::to_string(&computed)?
|
||||
)
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
@@ -347,7 +347,7 @@ fn yaml_test(file: &str) -> Result<()> {
|
||||
Err(e) => {
|
||||
// If Err is returned, it doesn't always get printed by cargo test.
|
||||
// Therefore, panic with the error.
|
||||
panic!("{}", e);
|
||||
panic!("{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user