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

Recursive binding added for local refs #298

Closed
tsandall opened this issue Mar 21, 2017 · 0 comments
Closed

Recursive binding added for local refs #298

tsandall opened this issue Mar 21, 2017 · 0 comments
Labels

Comments

@tsandall
Copy link
Member

Topdown is creating a recursive binding when evaluating local references.

E.g., given the following data:

{
 "strings": ["foo", "bar"]
}

And the following query (expr1; expr2; expr3):

data.s = x; x[0]; x[0]

Topdown creates the following bindings:

After expr1: locals={x: data.s} refs={}
After expr2: locals={x: data.s} refs={x[0]: data.s[0]}
After expr3: locals={x: data.s} refs={x[0]: data.s[0], data.s[0]: data.s[0]}

The recursive binding after expr3 is added because of

return Continue(t, PlugValue(ref, t.Binding), v, iter)

@tsandall tsandall added the bug label Mar 21, 2017
tsandall added a commit to tsandall/opa that referenced this issue Mar 22, 2017
If the entire ref is already bound, do not bother re-evaluating it. This
prevents a recursive binding from being added in the case where the same
local ref appears twice and is bound to a data ref. The fix for open-policy-agent#238 was
caused a stack overflow in this case!

Fixes open-policy-agent#298
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

1 participant