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>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-06 22:31:09 +00:00
committed by GitHub
parent 03c4275855
commit 5ae1d8abf2
3 changed files with 5 additions and 1 deletions

View File

@@ -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()

View File

@@ -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() =>
{

View File

@@ -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"