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
Variables declared as function arguments should shadow built-in functions. For example:
> f(object) { object[_] == 1 }
1 error occurred: 1:13: rego_type_error: match error
left : ???
right : number
In this case the type checker generates a match error because it thinks object[_] refers to the built-in function namespace that includes the new object.get function. This issue is not specific to the new object namespace, e.g., the same issue happens w/ other built-in functions:
> f(http) { http[_] == 1 }
1 error occurred: 1:11: rego_type_error: match error
left : ???
right : number
The problem is that vars declared in function argument lists are not being rewritten.
The text was updated successfully, but these errors were encountered:
Vars declared as rule args were not being rewritten which lead to
namespace conflicts with built-in functions. For example, definitions
like `f(object) { object[x] = 1 }` would generate type checking errors
because the checker would treat `object[x] = 1` as referring to the
`object` built-in function namespace.
This change updates the compiler to rewrite rule arguments just like
it does other declared variables.
Fixesopen-policy-agent#2080
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Vars declared as rule args were not being rewritten which lead to
namespace conflicts with built-in functions. For example, definitions
like `f(object) { object[x] = 1 }` would generate type checking errors
because the checker would treat `object[x] = 1` as referring to the
`object` built-in function namespace.
This change updates the compiler to rewrite rule arguments just like
it does other declared variables.
Fixes#2080
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Variables declared as function arguments should shadow built-in functions. For example:
In this case the type checker generates a match error because it thinks
object[_]
refers to the built-in function namespace that includes the newobject.get
function. This issue is not specific to the newobject
namespace, e.g., the same issue happens w/ other built-in functions:The problem is that vars declared in function argument lists are not being rewritten.
The text was updated successfully, but these errors were encountered: