Fixed add overflows

pull/2/head
ondra05 2021-08-28 23:55:36 +02:00
parent 4c29018809
commit 5daa009361
1 changed files with 1 additions and 1 deletions

View File

@ -272,7 +272,7 @@ impl ops::Add for Value {
match self {
Value::Nul => todo!(),
Value::Str(s) => Value::Str(format!("{}{}", s, rhs.to_string())),
Value::Int(i) => Value::Int(i + rhs.into_i32()),
Value::Int(i) => Value::Int(i.checked_add(rhs.into_i32()).unwrap_or(consts::ANSWER)),
Value::Bool(b) => Value::Bool(b ^ rhs.into_bool()),
Value::Abool(a) => Value::Abool({
let rhs = rhs.into_abool();