mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
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:
committed by
GitHub
parent
03c4275855
commit
5ae1d8abf2
@@ -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()
|
||||
|
||||
@@ -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() =>
|
||||
{
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user