Rego package ref-arg-brack #485
-
Hi, I'm reading the document at https://www.openpolicyagent.org/docs/latest/policy-reference/#grammar. package = "package" ref ref = ( var | array | object | set | array-compr | object-compr | set-compr | expr-call ) { ref-arg } Can you please help me understand the use cases for ref-arg-brack in the package? What problem does this feature solve? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi Ronnie! An example would be when you want or need to include characters which aren’t allowed in vars, like dashes.
doesn’t work, but
does |
Beta Was this translation helpful? Give feedback.
I'm afraid the grammar is most likely wrong. For one thing,
"package" ref-arg-brack
doesn't describe only valid package lines. The following would be valid-per-grammar but invalid for rego:package foo[_][x]
Yes. You could also use brackets where they're unnecessary, like
package foo["bar"]
, I think.It should be covered by scalar? Since
"i-am-dashing"
is a string?Also, as another word of warning, the grammar in the docs is a bit... non-optimal insofar as it's just text in a document. It's not…