From 3cfde406d3821943a8819403eec3bf0aa851d4c5 Mon Sep 17 00:00:00 2001 From: Seymur Bagirov Date: Mon, 6 Jan 2025 20:17:01 +0400 Subject: [PATCH] chore: fix comment pos i've moved comma but forgot to move the comment --- src/interpreter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index 4a13bef..302657b 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -66,10 +66,10 @@ fn binary( (Plus, Number(left), String(right)) => Ok(String(format!("{left}{right}"))), (Slash, Number(left), Number(right)) => Ok(Number(left / right)), (Star, Number(left), Number(right)) => Ok(Number(left * right)), + /* comma operator discard the left operand, so we just return the evaluation of the right operand */ (Comma, _,_) => Ok(right.clone()), (Greater | GreaterEqual | Less | LessEqual | Minus | Slash | Star, _, _) => Err(RuntimeError::new(op, "Operands must be numbers")), (Plus, _, _) => Err(RuntimeError::new(op, "Operands must be two numbers or two strings")), - /* comma operator discard the left operand, so we just return the evaluation of the right operand */ _ => unreachable!("Shouldn't happen. Expr::Binary for interpret. Some case is a binary operation that wasn't matched") }