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

ast: Fixing bug where comprehensions in rule else-heads weren't rewritten correctly #5772

Conversation

johanfylling
Copy link
Contributor

@johanfylling johanfylling commented Mar 18, 2023

Previously, vars in the rule head were only rewritten for the "primary" rule,
and not for else branches. This has been fixed by walking the head of each branch
and rewriting all vars found.

Fixes: #5771

@johanfylling johanfylling force-pushed the jf/5771/else_value_comprehension_bug branch from 4d38d94 to e1970b8 Compare March 20, 2023 14:13
@johanfylling johanfylling marked this pull request as ready for review March 20, 2023 16:21
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change and tests look good. Let's add a comment either in the code or commit message about why we moved the rewrite logic in the rewriteLocalVarsInRule method.

@johanfylling johanfylling force-pushed the jf/5771/else_value_comprehension_bug branch from e1970b8 to 3c24900 Compare March 20, 2023 22:54
…tten correctly

Previously, vars in the rule head were only rewritten for the "primary" rule,
and not for else branches. This has been fixed by walking the head of each branch
and rewriting all vars found.

Fixes: open-policy-agent#5771

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
@johanfylling johanfylling force-pushed the jf/5771/else_value_comprehension_bug branch from 3c24900 to 918aaa2 Compare March 20, 2023 22:56
@johanfylling johanfylling merged commit bdd4604 into open-policy-agent:main Mar 21, 2023
@johanfylling johanfylling deleted the jf/5771/else_value_comprehension_bug branch March 21, 2023 09:41
johanfylling added a commit to johanfylling/opa that referenced this pull request Mar 21, 2023
…tten correctly (open-policy-agent#5772)

Previously, vars in the rule head were only rewritten for the "primary" rule,
and not for else branches. This has been fixed by walking the head of each branch
and rewriting all vars found.

Fixes: open-policy-agent#5771

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
(cherry picked from commit bdd4604)
johanfylling added a commit that referenced this pull request Mar 21, 2023
…tten correctly (#5772)

Previously, vars in the rule head were only rewritten for the "primary" rule,
and not for else branches. This has been fixed by walking the head of each branch
and rewriting all vars found.

Fixes: #5771

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
(cherry picked from commit bdd4604)
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.

Safety check failing for vars in closures
3 participants