Skip to content

Conversation

@anakrish
Copy link
Collaborator

@anakrish anakrish commented Mar 31, 2024

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.

Closes #209
fixes #159

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>
@anakrish anakrish merged commit 316f3a7 into microsoft:main Apr 22, 2024
@anakrish anakrish deleted the early-return branch April 22, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Early Return from loops in a rule Support non-simple refs in rule heads

1 participant