feat: Handle literal comparisons that use = and comprehensions without loops

- emit AssertCondition for equality-only assignment plans (outside soft-assert mode) so rules like `0 = 1` fail under the VM just like the interpreter
- let comprehension bodies consume assertion failures by advancing or exiting their iteration context, both in run-to-completion and suspendable execution

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-12-03 12:59:58 -06:00
parent 8269968c4a
commit bedf667adc
6 changed files with 127 additions and 26 deletions
-5
View File
@@ -22,14 +22,10 @@ const OPA_BRANCH: &str = "v1.2.0";
const OPA_TODO_FOLDERS: &[&str] = &[
"aggregates",
"baseandvirtualdocs",
"comparisonexpr",
"dataderef",
"defaultkeyword",
"disjunction",
"elsekeyword",
"eqexpr",
"every",
"example",
"fix1863",
"functions",
"partialdocconstants",
@@ -38,7 +34,6 @@ const OPA_TODO_FOLDERS: &[&str] = &[
"refheads",
"sets",
"type",
"varreferences",
"virtualdocs",
"walkbuiltin",
"withkeyword",
+12
View File
@@ -48,3 +48,15 @@ cases:
}
query: data.test.main
want_result: true
- note: equality_literal_failure
data: {}
modules:
- |
package test
x if {
0 = 1
}
query: data.test.x
want_result: "#undefined"
+10
View File
@@ -13,3 +13,13 @@ cases:
main := [(x * 2) | some x in [1, 2, 3]]
query: data.test.main
want_result: [2, 4, 6]
- note: comprehension_equality_failure_returns_empty
data: {}
modules:
- |
package test
z := [x | x := 1; x == 2]
query: data.test.z
want_result: []