feat!: Introduce structured destructuring plans for bindings (#485)

- add a dedicated `compiler/destructuring_planner` feature that precomputes binding plans for assignments, parameters, and `some in` expressions
- enrich `ScopeContext` with same-scope tracking, local scheduling hints, and module globals so the planner enforces := shadowing rules without blocking parent scopes
- wire the planner through compiler, hoist, interpreter, and engine paths while updating binding plan variants and adding query traversal helpers for dependency analysis
- document the new planner architecture and ship interpreter regressions that exercise nested destructuring, shadowing, and error reporting

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-10-21 15:57:49 -05:00
committed by GitHub
parent 25a7ddad0a
commit 1e4ff952e6
27 changed files with 3334 additions and 1009 deletions

View File

@@ -253,9 +253,10 @@ pub fn eval_file(
query: &str,
enable_tracing: bool,
strict: bool,
v0: bool,
) -> Result<(Vec<Value>, Vec<String>)> {
let mut engine: Engine = Engine::new();
engine.set_rego_v0(true);
engine.set_rego_v0(v0);
engine.set_strict_builtin_errors(strict);
engine.set_gather_prints(true);
@@ -333,9 +334,10 @@ pub fn eval_file_with_rule_evaluation(
query: &str,
_enable_tracing: bool,
strict: bool,
v0: bool,
) -> Result<(Vec<Value>, Vec<String>)> {
let mut engine: Engine = Engine::new();
engine.set_rego_v0(true);
engine.set_rego_v0(v0);
engine.set_strict_builtin_errors(strict);
engine.set_gather_prints(true);
@@ -484,9 +486,19 @@ fn yaml_test_impl(file: &str) -> Result<()> {
}
}
}
#[cfg(not(feature = "graph"))]
{
// Skip tests that depend on graph builtin that need graph feature.
if file.contains("walk.yaml") {
std::println!("skipped {file} without graph feature.");
return Ok(());
}
}
std::println!("running {file}");
let v0 = !file.contains("bindings.yaml");
for case in test.cases {
std::print!("case {} ", case.note);
if case.skip == Some(true) {
@@ -516,6 +528,7 @@ fn yaml_test_impl(file: &str) -> Result<()> {
case.query.as_str(),
enable_tracing,
case.strict,
v0,
)
}
#[cfg(not(feature = "azure_policy"))]
@@ -530,6 +543,7 @@ fn yaml_test_impl(file: &str) -> Result<()> {
case.query.as_str(),
enable_tracing,
case.strict,
v0,
)
};