Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler/hoist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ impl LoopHoister {
query: &Query,
parent_context: &ScopeContext,
) -> Result<ScopeContext> {
self.lookup.ensure_query_capacity(module_idx, query.qidx);
let mut context = parent_context.clone();
context.current_scope_bound_vars = parent_context.current_scope_bound_vars.clone();

Expand Down
8 changes: 7 additions & 1 deletion src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3375,6 +3375,7 @@ impl Interpreter {
pub fn eval_default_rule_for_compiler(&mut self, rule_path: &str) -> Result<Value> {
self.input = Value::Undefined;
self.data = Value::Undefined;
self.ensure_loop_var_values_capacity();

let default_rules = self.compiled_policy.default_rules.get(rule_path).cloned();

Expand Down Expand Up @@ -4088,7 +4089,12 @@ impl Interpreter {

// Populate loop hoisting lookup table
use crate::compiler::hoist::LoopHoister;
let hoister = LoopHoister::new();
// Re-run hoisting with the analyzer's schedule so statement order is preserved.
let hoister = if let Some(schedule) = compiled_policy.schedule.clone() {
LoopHoister::new_with_schedule(schedule)
} else {
LoopHoister::new()
};
let loop_lookup = hoister.populate(compiled_policy.modules.as_ref())?;
compiled_policy.loop_hoisting_table = loop_lookup;

Expand Down
Loading
Loading