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/parser: fresh wildcards for chained function heads #5426

Conversation

srenatus
Copy link
Contributor

This is a spiritual follow-up to #5412.

A policy like

f(_) := 1 { true } { true } { true }

would have been pretty-printed as

f(_0) := 1
f(_0) := 1
f(_0) := 1

because of the duplicated wildcards.

They now get the same treatment as "else" gets: fresh wildcards.

This is a spiritual follow-up to open-policy-agent#5412.

A policy like

    f(_) := 1 { true } { true } { true }

would have been pretty-printed as

    f(_0) := 1
    f(_0) := 1
    f(_0) := 1

because of the duplicated wildcards.

They now get the same treatment as "else" gets: fresh wildcards.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
@srenatus srenatus marked this pull request as ready for review November 29, 2022 13:05
Copy link
Contributor

@philipaconrad philipaconrad left a comment

Choose a reason for hiding this comment

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

This seems like a pretty straightforward way to fix the wildcards issue. LGTM!

var rules []*Rule

rules = append(rules, &rule)
rules := []*Rule{&rule}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a small, but good refactoring. 👍

@netlify
Copy link

netlify bot commented Nov 29, 2022

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit ea4666a
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/63863e3f1541570008b98ec8
😎 Deploy Preview https://deploy-preview-5426--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@srenatus srenatus merged commit 9354f89 into open-policy-agent:main Nov 29, 2022
@srenatus srenatus deleted the sr/ast/parser-new-wildcards-for-chained-func-heads branch November 29, 2022 17:56
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.

None yet

2 participants