From a81adf888e977264bdeeeebd0f420bbf2d381647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Thu, 19 Jan 2023 19:09:59 +0100 Subject: [PATCH] Interpreter - String conversion when using the + operator --- src/interpreter/interpretable.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/interpreter/interpretable.rs b/src/interpreter/interpretable.rs index a03cc8f..79099c4 100644 --- a/src/interpreter/interpretable.rs +++ b/src/interpreter/interpretable.rs @@ -417,6 +417,12 @@ fn on_binary( TokenType::Plus => match (left_value, right_value) { (Value::Number(a), Value::Number(b)) => Ok(Value::Number(a + b).into()), (Value::String(a), Value::String(b)) => Ok(Value::String(a + &b).into()), + (a, Value::String(b)) => { + Ok(Value::String(a.convert_to_string(es, operator)? + &b).into()) + } + (Value::String(a), b) => { + Ok(Value::String(a + &b.convert_to_string(es, operator)?).into()) + } _ => error(operator, "type error"), },