Skip to content

Commit b148809

Browse files
plotnickdhatch
andcommitted
Partial cleanups in VM (#667)
* Refactor some *_op_helper methods into query_op_helper Done: arithmetic, comparisons. Todo: in, isa. Probably not: unify, dot. * Refactor in_op_helper to use new query_op_helper * Add add_constraint method. * Use add constraint in unify vars. * Format, fix some comments, and the tests. * Refactor dot_op_helper to use query_op_helper. * Bump flask-oso dependencies. * Fix some (but not all) JS tests. * Actually fix JS tests. This reverts commit 304dfe4, and instead fixes the underlying problem, which was that we were losing source information in sub-queries. * Fix more tests, appease 📎. * Mypy 0.800 compatibility See python/mypy#9940 * Clean up comments & error messages in add_constraint. * Move `dot_op_helper` below `query_op_helper`. * Remove misleading comments. * Fix TODO based on review suggestion. * Re-mute logs during rule selection. * Better TODO comment. * Update flask-oso oso requirement. Co-authored-by: David Hatch <[email protected]>
1 parent 4484c95 commit b148809

File tree

4 files changed

+322
-432
lines changed

4 files changed

+322
-432
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
oso~=0.10.0
1+
oso~=0.11.0a0
22
flask>=0.12.0

polar-core/src/partial/partial.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl Operation {
163163
| (Value::Boolean(_), Value::Number(_))
164164
| (Value::Boolean(_), Value::Boolean(_))
165165
| (Value::String(_), Value::String(_)) => {
166-
if compare(&o.operator, left, right) {
166+
if compare(o.operator, &left, &right) {
167167
TRUE
168168
} else {
169169
self.consistent = false;
@@ -937,14 +937,8 @@ mod test {
937937
let p = Polar::new();
938938
p.load_str("f(x) if x = x + 0;")?;
939939
let mut q = p.new_query_from_term(term!(call!("f", [sym!("x")])), false);
940-
let error = q.next_event().unwrap_err();
941-
assert!(matches!(
942-
error,
943-
PolarError {
944-
kind: ErrorKind::Runtime(RuntimeError::Unsupported { .. }),
945-
..
946-
}
947-
));
940+
assert_partial_expression!(next_binding(&mut q)?, "x", "_this + 0 = _this");
941+
assert_query_done!(q);
948942
Ok(())
949943
}
950944

0 commit comments

Comments
 (0)