mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Fix scheduling regression (#53)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
ef36d9bed5
commit
639ba72c90
@@ -2348,7 +2348,17 @@ impl Interpreter {
|
||||
}
|
||||
v => v,
|
||||
};
|
||||
|
||||
let paths: Vec<&str> = path.iter().map(|s| *s.text()).collect();
|
||||
|
||||
if let RuleHead::Set { .. } = &rule_head {
|
||||
// Ensure that sets are created as empty.
|
||||
let vref = Self::make_or_get_value_mut(&mut self.data, &paths)?;
|
||||
if *vref == Value::Undefined {
|
||||
*vref = Value::new_set();
|
||||
}
|
||||
}
|
||||
|
||||
self.update_data(span, refr, &paths[..], value)?;
|
||||
|
||||
self.processed.insert(rule.clone());
|
||||
|
||||
@@ -162,6 +162,8 @@ pub fn schedule<Str: Clone + std::cmp::Ord + std::fmt::Debug>(
|
||||
(stmt_scheduled, reprocess_var)
|
||||
};
|
||||
|
||||
process_var(empty.clone());
|
||||
|
||||
let mut done = false;
|
||||
while !done {
|
||||
done = true;
|
||||
@@ -840,7 +842,7 @@ impl Analyzer {
|
||||
)?;
|
||||
self.process_comprs(&comprs[..], scope, first_use, &mut used_vars)?;
|
||||
definitions.push(Definition {
|
||||
var: expr.span().source_str().clone(),
|
||||
var: expr.span().source_str().clone_empty(),
|
||||
used_vars,
|
||||
});
|
||||
Ok(())
|
||||
|
||||
@@ -21,3 +21,52 @@ cases:
|
||||
query: data.test
|
||||
want_result:
|
||||
r1: 12
|
||||
|
||||
- note: input-dependency
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
default p = null
|
||||
p = input.p
|
||||
|
||||
q {
|
||||
input.p
|
||||
true
|
||||
}
|
||||
|
||||
r1 = s {
|
||||
# Dependency on null input before erroring stmt.
|
||||
input.p
|
||||
s = concat("", ["", p])
|
||||
}
|
||||
|
||||
#r2 = s {
|
||||
# s = concat("", ["", p])
|
||||
# # Dependency on null input after erroring stmt.
|
||||
# # This doesn't reordered before assignment to s
|
||||
# # since s also has no other local var dependency.
|
||||
# # The written order of statements is preserved.
|
||||
# input.p
|
||||
#}
|
||||
|
||||
r3 = s {
|
||||
# Indirect dependency on null input before erroring stmt.
|
||||
q
|
||||
s = concat("", ["", p])
|
||||
}
|
||||
|
||||
#r3 = s {
|
||||
# s := concat("", ["", p])
|
||||
# # Indirect dependency on null input after erroring stmt.
|
||||
# # This doesn't reordered before assignment to s
|
||||
# # since s also has no other local var dependency.
|
||||
# # The written order of statements is preserved.
|
||||
# input.p
|
||||
# q
|
||||
#}
|
||||
|
||||
query: data.test
|
||||
want_result:
|
||||
p: null
|
||||
|
||||
Reference in New Issue
Block a user