mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
480281741b
- Refactored the checkSafetyBody function
* Moved reordering into separate function with well defined interface.
* Replaced ad-hoc maps to track sets of Vars with VarSet.
* Added helper functions to get Vars on expressions, rules, etc. This
makes the re-ordering much clearer.
- Updated test cases for DFS and re-ordering.
- Added comment in DFSTraversal to help callers consider whether
the Visited state needs to be reset.
Also, fixed two separate bugs:
- When computing output variables in positions that unify recursively,
variable object keys should not be included (as the unification implementation
won't unify these.)
- When computing output variables, variables found in references (other than
the head) WILL be bound, so they should be included in the result. For
example:
> a = [1,2,3], a[i] != 2
In this case, "i" will be bound so it should be included in the output
variables for the expression.