From ff0adf054eae90af3ee150c0fc034cb5871675fd Mon Sep 17 00:00:00 2001 From: Anand Krishnamoorthi <35780660+anakrish@users.noreply.github.com> Date: Tue, 28 May 2024 09:25:13 -0400 Subject: [PATCH] every: non collections should evaluate to false (#253) See https://github.com/open-policy-agent/opa/pull/6763 Signed-off-by: Anand Krishnamoorthi --- src/interpreter.rs | 7 +++---- tests/interpreter/cases/every/tests.yaml | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index a6a4233..f4ae621 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -791,10 +791,9 @@ impl Interpreter { } } } - Value::Undefined | Value::Null => r = false, - // Other types cause every to evaluate to true even though - // it is supposed to happen only for empty domain. - _ => (), + _ => { + r = false; + } }; self.contexts.pop(); self.scopes.pop(); diff --git a/tests/interpreter/cases/every/tests.yaml b/tests/interpreter/cases/every/tests.yaml index 685499e..43cff25 100644 --- a/tests/interpreter/cases/every/tests.yaml +++ b/tests/interpreter/cases/every/tests.yaml @@ -114,7 +114,6 @@ cases: x1: 100 x2: 100 x3: 100 - x4: 100 - note: negative data: {}