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/compile: 'every' rewriting steps #4231
Merged
srenatus
merged 20 commits into
open-policy-agent:main
from
srenatus:sr/ast/every-kw-rewriting
Jan 29, 2022
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
84c2c7c
ast: prealloc expression
srenatus 7f3380c
ast/visit: skip 'Every' Body when skipping closures
srenatus b1ce68b
ast/parser_ext: add MustParseModuleWithOpts, MustParseBodyWithOpts
srenatus 4f9e3da
ast/compile: 'every' rewriting (dynamic, declared vars)
srenatus 6f0b910
ast/compile: simplify every rewriting (key/val are vars)
srenatus 3227f5d
ast/compile: deal with wildcard cases
srenatus 22ced5d
ast/compile: add missing stack.Pop()
srenatus b757da8
ast/compile_test: fix indentation
srenatus 00e3896
ast/compile: fix output vars of 'every' body
srenatus ddd81d8
ast/compile: safety check vars in every.Body
srenatus 8e78ae7
ast/compile_test: add nested case for every rewriting
srenatus 8ac09b4
ast/compiler: rewrite prints in 'every' bodies
srenatus 0b72c1c
ast/compile_test: add "rewrite dynamics" tests for "every"
srenatus 3954eb3
ast/compile: expand "every" domain
srenatus 0f1bfe0
ast/compile: outputVarsForExpr: don't return vars from "Every" body
srenatus 9289cb5
ast/compile: fix safety reordering for every
srenatus decbdb1
ast: rename (Every).Vars() -> (Every).KeyValueVars()
srenatus 5f41d87
ast/compile: use VarVisitor for KeyValueVars()
srenatus 46478b6
ast/compile: add ContainsClosures
srenatus 5f5da56
ast/compile_test: add unused assigned var in "every" body case
srenatus File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a trap:
WalkClosures
checks that its node in question is of type *Every. So, when passing a function, you get anx
of type *Every, and to walk its actual closure, theevery.Body
, it'll have to be done like this.I wonder if there's a better approach here. Having
WalkClosures
applyf
toev.Body
here would not allow us to differentiate what we've been called on when we need it, here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unavoidable due to the scoping rules we've implemented for
every
. Presumably it'll be the same for any other keywords we add that support closures and local variable declaration. This seems like the best we can do.