From e95e0744c6f9504aa735b9c93857b3a8171bf711 Mon Sep 17 00:00:00 2001 From: Erin Date: Sat, 28 Aug 2021 23:55:36 +0200 Subject: [PATCH] Fixed add overflows --- ablescript/src/variables.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index 544f29f..20f0031 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -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();