Evaluator - Neq
Currently we need a separate branch for neq in arrays since they use predicates. In the future, we may be able to allow more code to be shared here. Although, it's not strictly a problem
use super::{invert, sub::handle_sub_op};
-use crate::{Evaluator, Object, RuntimeErrorKind};
+use crate::{object::Array, Evaluator, Object, RuntimeErrorKind};
/// This calls the sub op under the hood
/// Then asserts that the result has an inverse
@@ -9,8 +9,15 @@ pub fn handle_neq_op(
right: Object,
evaluator: &mut Evaluator,
) -> Result<Object, RuntimeErrorKind> {
+ match (left, right) {
+ (Object::Array(left_arr), Object::Array(right_arr)) => {
+ Array::not_equal(left_arr, right_arr, evaluator)?;
+ }
+ (left, right) => {
let result = handle_sub_op(left, right, evaluator)?;
// Add an inversion to ensure that the inverse exists
let _ = invert(result, evaluator);
+ }
+ }
Ok(Object::Null)
}
