Skip to content

Add support for the and and or logical operators - #26

Open
sspaink wants to merge 1 commit into
FallenAngel97:masterfrom
sspaink:logical-operators
Open

Add support for the and and or logical operators#26
sspaink wants to merge 1 commit into
FallenAngel97:masterfrom
sspaink:logical-operators

Conversation

@sspaink

@sspaink sspaink commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Adds the OPA future keywords and and or (https://github.com/open-policy-agent/opa/milestone/1), which is planned to be in the next release (v1.20.0). So getting IDE support ready.

Part of open-policy-agent/opa#8999, were we are tracking the other places this update is needed e.g. open-policy-agent/vscode-opa#482

Adds the OPA future keywords `and` and `or` to the grammar at the literal
level rather than inside `expr`, since they combine bodies rather than
terms. Precedence, tightest first: not > and > or > with. Both operators
are left-associative, and `logical_group` allows parenthesized regrouping
such as `(a or b) and c`.

A parenthesized `with` is also a group: a trailing modifier binds to the
whole logical expression, and OPA rejects `a with x as y and b` at parse
time, so parens are the only way to scope a modifier to a single operand
(`(a with x as y) and b`) — `opa fmt` preserves them for that reason.
Requiring a with-modifier there keeps the group disjoint from the existing
expr-parens term, so `(a)` and `(not a)` remain ordinary parenthesized
expressions.

Includes the v1 comp+if variants (`logical_and_v1` / `logical_or_v1`),
highlight queries for the new keywords, and a corpus of tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant