From 5ae1d8abf22d800da7b7bb8eccad32c74887a1f8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 6 May 2026 22:31:09 +0000 Subject: [PATCH] chore: clarify bracket-head rule semantics Agent-Logs-Url: https://github.com/microsoft/regorus/sessions/272a971a-ae52-45ae-8cb3-714e747599c4 Co-authored-by: anakrish <35780660+anakrish@users.noreply.github.com> --- src/interpreter.rs | 2 ++ src/languages/rego/compiler/rules.rs | 2 ++ tests/rvm/vm/suites/object_operations.yaml | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index f88c14a..5e9ea84 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -1757,6 +1757,8 @@ impl Interpreter { match expr.as_ref() { Expr::Var { span, .. } => { + // A variable that is not currently bound in local scope behaves like + // a stable global/package reference for this evaluation. let scope = self .scopes .last() diff --git a/src/languages/rego/compiler/rules.rs b/src/languages/rego/compiler/rules.rs index 091a478..825e2a4 100644 --- a/src/languages/rego/compiler/rules.rs +++ b/src/languages/rego/compiler/rules.rs @@ -56,6 +56,8 @@ impl<'a> Compiler<'a> { match head { RuleHead::Set { .. } => RuleType::PartialSet, RuleHead::Compr { refr, assign, .. } => match refr.as_ref() { + // Variable-key bracket heads emit one object entry per successful + // binding, so they must compile as partial objects. crate::ast::Expr::RefBrack { index, .. } if super::expressions::try_eval_const(index.as_ref()).is_none() => { diff --git a/tests/rvm/vm/suites/object_operations.yaml b/tests/rvm/vm/suites/object_operations.yaml index fe3dc64..63a24e8 100644 --- a/tests/rvm/vm/suites/object_operations.yaml +++ b/tests/rvm/vm/suites/object_operations.yaml @@ -8,7 +8,7 @@ cases: - note: object_key_collision_conflict description: Setting same key twice with different values should raise a rule output conflict - example_rego: "p[\"key\"] := value if { value := [1, 2][_] }" + example_rego: "p[\"key\"] = value { value := [1, 2][_] }" literals: - {} - "key"