ast: Allow empty rule bodies - #8870
Draft
anderseknert wants to merge 1 commit into
Draft
Conversation
Since the dawn of time, unconditional rules have been represented
internally like this:
```rego
head := value if {
true
}
```
For about as long, the lone "true-expression" has been a bit of
an eye sore. A few nights ago, I set out to see how much of OPA
would break if we tried to get rid of this, and allow this type
of rule to be represented internally just like how it's written:
```rego
head := value
head contains value
```
Turns out, not a whole lot at all broke, and this is currently in
a state where all tests but ONE (`TestConcurrencyCompile`) passes
on my own machine. I don't fully understand why, so I'd appreciate
some help with that!
But more than anything, this is a request for feedback. Is this a
bad/good idea? Would we break anything somewhere? The lone true
expression feels like more of an implementation detail to me, but
considring how long it's been around, who knows if someone has
come to rely on that somehow..
Signed-off-by: Anders Eknert <anders.eknert@apple.com>
Member
Author
|
I'd love to see some benchmark metrics on this later! Regal shows little impact in terms of allocations, but seems consistently 4-5% faster on linting itself.. which is not little! |
|
This pull request has been automatically marked as stale because it has not had any activity in the last 30 days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the dawn of time, unconditional rules have been represented internally like this:
For about as long, the lone "true-expression" has been a bit of an eye sore. A few nights ago, I set out to see how much of OPA would break if we tried to get rid of this, and allow this type of rule to be represented internally just like how it's written:
Turns out, not a whole lot at all broke, and this is currently in a state where all tests but ONE (
TestConcurrencyCompile) passes on my own machine. I don't fully understand why, so I'd appreciate some help with that!But more than anything, this is a request for feedback. Is this a bad/good idea? Would we break anything somewhere? The lone true expression feels like more of an implementation detail to me, but considring how long it's been around, who knows if someone has come to rely on that somehow..