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

Cannot use dictionary in function head #467

Closed
jc-m opened this issue Oct 3, 2017 · 0 comments
Closed

Cannot use dictionary in function head #467

jc-m opened this issue Oct 3, 2017 · 0 comments
Labels

Comments

@jc-m
Copy link
Contributor

jc-m commented Oct 3, 2017

in this use case:
x {
"a": 1,
"b": 2
}

w = x.a {true}
w returns 1

r(obj) = x.a {true}
fails with:
1 error occurred: 1:1: rego_unsafe_var_error: var data is unsafe

the following form works:
r(obj) = num {true; num = x.a}

@tsandall tsandall added the bug label Oct 9, 2017
tsandall added a commit to tsandall/opa that referenced this issue Oct 10, 2017
Previously, functions were implemented with a separate set of types that
had their own code paths in the compiler, eval, etc. These changes
refactor the function implementation so that functions are implemented
as rules with one or more arguments.

By representing functions as rules, we can avoid special casing required
to support functions, e.g., during parse and compile there are a number
of steps that required special casing for functions:

- Parser needed separate grammar definitions for functions (which
  prevented them from being chained or using else)

- Compiler needed separate resolver and type checker implementations
  which was a source of bugs.

In some cases, special casing is unavoidable for now (e.g., during eval)
however this could be improved in the future.

Fixes open-policy-agent#471
Fixes open-policy-agent#467
Fixes open-policy-agent#463
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants