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

format: Deep copy inputs to avoid mutating the caller's copy #2440

Merged
merged 1 commit into from
May 29, 2020

Conversation

tsandall
Copy link
Member

As part of this change, also update the format package to unmangle the
variables slightly differently--just remove the wildcard prefix
instead of translating the variable names. This makes it easier to
tell where the variables came from in the first place and is a bit
less complicated.

Fixes #2439

Signed-off-by: Torin Sandall torinsandall@gmail.com

@tsandall tsandall requested a review from patrick-east May 27, 2020 18:40
expected: `input.arr[__wildcard0__]["some key"][_] = bar
input.arr[__wildcard0__].bar = qux
foo[__wildcard1__][__wildcard0__].bar = bar[__wildcard1__][_][__wildcard0__].bar
expected: `input.arr[01]["some key"][_] = bar
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC when we discussed this originally we decided to use a __wildcardXX__ style variable to avoid any potential collisions.. I guess you're less concerned about that now?

Also you sure that numbers as variable names is a good idea? (I'm actually surprised this would parse correctly, i thought vars had to start with ALPHA or _ )

Copy link
Member Author

Choose a reason for hiding this comment

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

@patrick-east I've updated the code to prepend and underscore. PTAL and merge if LGTY.

As part of this change, also update the format package to unmangle the
variables slightly differently--just remove the wildcard prefix
instead of translating the variable names. This makes it easier to
tell where the variables came from in the first place and is a bit
less complicated.

Fixes open-policy-agent#2439

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
@patrick-east patrick-east merged commit fe18f11 into open-policy-agent:master May 29, 2020
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.

format package unexpectedly mutating AST nodes
2 participants