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
Dashes are not allowed in (simple) rule names, and need to be quoted in refs. Users unaware of this will however not learn this from OPA, as this surprisingly parses and compiles:
package p
foo-bar :=1
It will not evaluate though (undefined). Compiling with strict mode on will result in an error, but not one you'd reasonably expect:
2 errors occurred:
policy.rego:3: rego_compile_error: unused argument foo. (hint: use _ (wildcard variable) instead)
policy.rego:3: rego_compile_error: unused argument bar. (hint: use _ (wildcard variable) instead)
Running opa fmt on this policy tells us what OPA seems to see here:
package p
minus(foo, bar) :=1
Which while it explains the observed behavior, doesn't explain why a dash (or a minus if you will) in between two words "expands" to minus with the symbols to the left and right as arguments.
Checking the AST confirms this representation as well, so this issue seems to be in the parser.
Desired behavior here would IMO be that this rendered an error explaining that the dash is not valid at that position.
The text was updated successfully, but these errors were encountered:
I should probably add that the dash/minus isn't special here — any operator (built-in function with an infix attribute) will behave the same way, i.e. p/q := 1, a+b := 2, etc. The dash is just most likely to be actually used here.
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.
Dashes are not allowed in (simple) rule names, and need to be quoted in refs. Users unaware of this will however not learn this from OPA, as this surprisingly parses and compiles:
It will not evaluate though (undefined). Compiling with strict mode on will result in an error, but not one you'd reasonably expect:
Running
opa fmt
on this policy tells us what OPA seems to see here:Which while it explains the observed behavior, doesn't explain why a dash (or a minus if you will) in between two words "expands" to
minus
with the symbols to the left and right as arguments.Checking the AST confirms this representation as well, so this issue seems to be in the parser.
Desired behavior here would IMO be that this rendered an error explaining that the dash is not valid at that position.
The text was updated successfully, but these errors were encountered: