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
According to the docs, the contains keyword can only be used as a syntactic sugar for partial set definitions. Unfortunately, the parser is more than happy to accept the keyword in function definitions, which causes a panic down the line in ast/compile later on.
This occurs because the parser (by design!) does not populate the rule.Head.Value field when parsing contains AST nodes, and this breaks how functions are handled later on in ast/compile where that value is assumed to be non-nil.
This panic case can be observed on the Rego Playground as well.
Example:
package test
import future.keywords.contains
p(id) contains x {
x := id
}
Previously, we did not detect misuses of the `contains` keyword, which
is only valid as a syntactic sugar for partial set definition rules.
This commit adds some logic to detect when a function rule head has been
paired with the `contains` keyword, which should generally be an error
condition.
Fixes: open-policy-agent#5525
Signed-off-by: Philip Conrad <[email protected]>
Previously, we did not detect misuses of the `contains` keyword, which
is only valid as a syntactic sugar for partial set definition rules.
This commit adds some logic to detect when a function rule head has been
paired with the `contains` keyword, which should generally be an error
condition.
Fixes: #5525
Signed-off-by: Philip Conrad <[email protected]>
Short description
According to the docs, the
contains
keyword can only be used as a syntactic sugar for partial set definitions. Unfortunately, the parser is more than happy to accept the keyword in function definitions, which causes a panic down the line inast/compile
later on.This occurs because the parser (by design!) does not populate the
rule.Head.Value
field when parsingcontains
AST nodes, and this breaks how functions are handled later on inast/compile
where that value is assumed to be non-nil.This panic case can be observed on the Rego Playground as well.
Example:
Result:
Expected Behavior
The text was updated successfully, but these errors were encountered: