microsoft / regorus

Regorus - A fast, lightweight Rego (OPA policy language) interpreter written in Rust.
MIT License
106 stars 27 forks source link

Early Return from loops in a rule #209

Closed anakrish closed 2 months ago

anakrish commented 2 months ago

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.