Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

early return #189

Merged
merged 1 commit into from
Apr 22, 2024
Merged

early return #189

merged 1 commit into from
Apr 22, 2024

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
4 checks passed
@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