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

Initial type checking implementation #312

Merged
merged 10 commits into from
Apr 26, 2017

Conversation

tsandall
Copy link
Member

These changes add basic support for type inference and type checking.

Type inference covers queries (i.e., terms/vars inside queries) as well as virtual docs. Type information for base docs is not available yet--and type checking treats base docs as having "any" type.

Type inference and checking are performed in one pass. The output of the type checking phase is a type environment that contains all relevant type information (for the query or rule set).

Type inference and checking for virtual docs is performed bottom-up after topologically sorting the rules. In the future, we could investigate relaxing this so that type errors/conflicts in base documents could be detected.

Currently, type checking handles the following:

  1. Built-in arguments
  2. Reference arguments

tsandall added 10 commits April 25, 2017 20:18
The types package defines the data types in OPA. The types themselves
are comparable. The Any type represents a set of types for cases where a
static value cannot be assigned. An empty Any type is the superset of
all types (and sets of types).
Given a parsed rule, it should be easy to determine the path of the
document produced by that rule without having access to the entire that
the rule is contained in.
Copy link
Member

@timothyhinrichs timothyhinrichs left a comment

Choose a reason for hiding this comment

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

Looks great! Can't wait to get this in place!

@timothyhinrichs timothyhinrichs merged commit 3690fe8 into open-policy-agent:master Apr 26, 2017
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.

2 participants