Interpreter - String conversion when using the + operator
This commit is contained in:
parent
c26ae0c053
commit
a81adf888e
1 changed files with 6 additions and 0 deletions
|
@ -417,6 +417,12 @@ fn on_binary(
|
||||||
TokenType::Plus => match (left_value, right_value) {
|
TokenType::Plus => match (left_value, right_value) {
|
||||||
(Value::Number(a), Value::Number(b)) => Ok(Value::Number(a + b).into()),
|
(Value::Number(a), Value::Number(b)) => Ok(Value::Number(a + b).into()),
|
||||||
(Value::String(a), Value::String(b)) => Ok(Value::String(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"),
|
_ => error(operator, "type error"),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue