diff --git a/src/operator/mod.rs b/src/operator/mod.rs index 1be227d..a131b55 100644 --- a/src/operator/mod.rs +++ b/src/operator/mod.rs @@ -95,7 +95,7 @@ impl Operator { // Make this a const fn once #57563 is resolved fn is_flatten_chains(&self) -> bool { match self { - Operator::Chain => true, + Operator::Tuple => true, _ => false, } } @@ -112,7 +112,8 @@ impl Operator { use crate::operator::Operator::*; match self { Add | Sub | Mul | Div | Mod | Exp | Eq | Neq | Gt | Lt | Geq | Leq | And | Or - | Tuple | Assign | Chain => Some(2), + | Assign | Chain => Some(2), + Tuple => None, Not | Neg | RootNode => Some(1), Const { value: _ } => Some(0), VariableIdentifier { identifier: _ } => Some(0), diff --git a/src/tree/mod.rs b/src/tree/mod.rs index e9f50d8..b763e9b 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -11,6 +11,8 @@ use crate::{ operator::*, value::Value, }; +use std::error::Error; +use std::any::Any; mod display; mod iter; @@ -383,7 +385,7 @@ impl Node { .last_mut() .unwrap() .insert_back_prioritized(node, false) - } else if self.children.last().unwrap().operator().id() == node.operator().id() && node.operator().is_flatten_chains() && !self.children.last().unwrap().has_enough_children() { + } else if self.children.last().unwrap().operator().type_id() == node.operator().type_id() && node.operator().is_flatten_chains() && !self.children.last().unwrap().has_enough_children() { // The operators will be chained together, and the next value will be added to this nodes last child. Ok(()) } else {