mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-27 10:45:08 -06:00
b647eb7e71
With these changes, the REPL can now print expression values more reliably. E.g., simple expressions like 3+5 just do the right thing. Previously the REPL called topdown directly and reimplemented some of the logic to format result sets. This was a source of issues because it was possible for the rego package and the REPL to return different answers. With these changes, the REPL and rego package results are equivalent. A few changes were required. Specifically: * Query Compiler. Updated to accept user supplied stages. This way users can perform their own rewriting. This is used by the rego package to provide the query+functional semantics we want. In the future, this API could be used to register custom optimization passes to the compiler. * Compiler. Expose GetArity helper. This allows users to quickly lookup the arity of a function referred to by a ref. The rego package needs this to decide whether to capture call outputs. * Rego package. Expose new args to set parse package, imports, etc. This is used by the REPL which maintains state to control the currently active module.