diff --git a/src/eval.rs b/src/eval.rs index 80c1d24..e4b826c 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -85,7 +85,7 @@ impl ExprVisitor> for InterpreterRunner<'_> ) -> Result { let operand = self.visit_expr(expr)?; match operator.kind() { - TokenKind::Minus => evaluate_negation(operand, operator), + TokenKind::Minus => evaluate_negation(&operand, operator), TokenKind::Bang => Ok(EvaluatedValue::Boolean(!operand.is_truthy())), _ => unreachable!( "attempted to evaluate non-unary operator as unary operator: {:?}", @@ -274,7 +274,7 @@ fn evaluate_addition( _ => Err(ScriptError { line: operator.line(), location: String::new(), - message: format!("left and right operands must be both numbers or both strings"), + message: "left and right operands must be both numbers or both strings".to_string(), }), } } @@ -291,7 +291,7 @@ fn evaluate_binary_arithmetic EvaluatedValue>( } fn evaluate_negation( - operand: EvaluatedValue, + operand: &EvaluatedValue, operator: &Token, ) -> Result { match operand { @@ -299,7 +299,7 @@ fn evaluate_negation( _ => Err(ScriptError { line: operator.line(), location: String::new(), - message: format!("operand must be a number"), + message: "operand must be a number".to_string(), }), } }