You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package play
f(x, y) {
x[y]
}
p {
input.foo = _
f(input, "bar") # THIS STATEMENT IS NOT REWRITTEN PROPERLY
}
Tracing shows the issue:
Enter data.play = _
| Eval data.play = _
| Index data.play = _ (matched 1 rule)
| Index data.play = _ (matched 1 rule)
| Enter data.play.p
| | Eval input.foo = _
| | Eval data.play.f(input, "bar") # THIS STATEMENT IS WRONG
-------8< SNIP 8<---------
The last expression shown in the trace above is incorrect. The first operand (input) should have been assigned to a local variable and then substituted in the call. If the call was to a built-in function the OPA would return an error (since it would end up passing a variable to the built-in function implementation, which is illegal.)
The text was updated successfully, but these errors were encountered:
Earlier if a reference to the root of the input document was passed as operand in a call, it would not be rewritten to a local variable and substituted in the call. Refs to non-root input/data document would be rewritten. This was happening because we were updating the value of the input root ref term to a variable and as a result the compiler stage that rewrites the body of dynamic terms ('rewriteDynamicTerms') would not rewrite the input root ref. These changes modify the 'rewriteLocalVars' stage so that the value of root ref term is updated based on whether its value is an explicitly declared variable. If it isn't, then it will be rewritten in a later stage.
Fixesopen-policy-agent#2084
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Earlier if a reference to the root of the input document was passed as operand in a call, it would not be rewritten to a local variable and substituted in the call. Refs to non-root input/data document would be rewritten. This was happening because we were updating the value of the input root ref term to a variable and as a result the compiler stage that rewrites the body of dynamic terms ('rewriteDynamicTerms') would not rewrite the input root ref. These changes modify the 'rewriteLocalVars' stage so that the value of root ref term is updated based on whether its value is an explicitly declared variable. If it isn't, then it will be rewritten in a later stage.
Fixes#2084
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
For example:
Tracing shows the issue:
The last expression shown in the trace above is incorrect. The first operand (
input
) should have been assigned to a local variable and then substituted in the call. If the call was to a built-in function the OPA would return an error (since it would end up passing a variable to the built-in function implementation, which is illegal.)The text was updated successfully, but these errors were encountered: