fix: reject some-in bindings that also appear in the domain - #9062
Open
BetterAndBetterII wants to merge 2 commits into
Open
fix: reject some-in bindings that also appear in the domain#9062BetterAndBetterII wants to merge 2 commits into
BetterAndBetterII wants to merge 2 commits into
Conversation
some i, x in xs[i] compiled because the domain was rewritten after the binding. Treat that overlap as a compile error. Fixes open-policy-agent#9052 Signed-off-by: Yuzhong Zhang <BetterAndBetterII@users.noreply.github.com>
BetterAndBetterII
force-pushed
the
fix/some-in-self-ref
branch
from
August 20, 2026 19:10
58fb8fe to
086d307
Compare
anderseknert
left a comment
Member
There was a problem hiding this comment.
Thank you! Left a comment or two on implementation details, but besides that looking good to me 👍
| if val != nil { | ||
| bound.Update(val.Vars()) | ||
| } | ||
| domainVis := NewVarVisitor().WithParams(VarVisitorParams{SkipClosures: true}) |
Member
There was a problem hiding this comment.
Should we not get this from the pool instead and return it later, as we do elsewhere in this file?
vis := varVisitorPool.Get()
| if v0.IsWildcard() { | ||
| continue | ||
| } | ||
| errs = append(errs, NewError(CompileErr, decl.Loc(), "var %v used in some domain", v0)) |
Member
There was a problem hiding this comment.
While some domain may be technically correct, I'm not sure all policy authors would know what that means. What do you think about tweaking the "var i assigned above" error you'd normally see if you tried to bind i before the some to say var i assigned before or something like that?
Signed-off-by: Yuzhong Zhang <BetterAndBetterII@users.noreply.github.com>
BetterAndBetterII
force-pushed
the
fix/some-in-self-ref
branch
from
August 28, 2026 05:56
ffd048f to
476b193
Compare
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.
some i, x in xs[i] compiled because the domain was rewritten after the binding. Treat that overlap as a compile error. Fixes #9052.