diff --git a/src/parser/ast.rs b/src/parser/ast.rs index afd1fce..b061d0f 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -645,13 +645,12 @@ pub mod canonical { Expr::Number(tail) } Expr::Binary(head, tails) => { + let mut tails = tails.into_iter().map(|(op, tail)| (op, tail.to_canonical())); let mut head = match head.to_canonical() { Expr::Number(n) => n, - head => return Expr::Binary(head.into(), tails), + head => return Expr::Binary(head.into(), tails.collect()), }; - let mut tails = tails.into_iter(); for (op, tail) in &mut tails { - let tail = tail.to_canonical(); // If the canonical tail isn't a number, rebuild and return let Expr::Number(tail) = tail else { return Expr::Binary(