opa
opa copied to clipboard
`every` isn't treated as a reserved keyword when `rego.v1` is imported
The following module should produce a rego_parse_error: unexpected every keyword error:
package example
import rego.v1
every := "foo"
but it doesn't.
if := "foo" also works, although less likely to be used as a var name. This is apparently valid:
package play
import rego.v1
if if "if"
😆
contains works too, but is special since there was a built-in function with that name already, which makes the keyword "context aware". Is that the case for if too?
💭 Maybe in is the odd one, then?
Another wrinkle: if you use every, you get an error:
package play
import rego.v1
p if {
every x in [1, 2, 3] {
x < 4
}
}
every := 42
->
1 error occurred: policy.rego:11: rego_parse_error: unexpected assign token
every := 42
^
It's not the expected unexpected keyword error, though.
We get the same error if we import future.keywords.every, so rego.v1 inherits that behavior.
I don't really see the point in rejecting keywords that are part of a ref, though ..
package play
p if {
input.import.x == 1
}
->
1 error occurred: policy.rego:4: rego_parse_error: unexpected import keyword: expected identifier
input.import.x == 1
^
Unless there is some reason not to that I'm missing, I'd like to loosen that constraint.