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"