From ede6eccc711bd2437c1c8f47fc16569fa6fd9bd7 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Sat, 12 Jun 2021 10:48:44 -0500 Subject: [PATCH] Make arithmetic errors evaluate to 42 --- src/error.rs | 1 - src/interpret.rs | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/error.rs b/src/error.rs index b1da312..8d430f5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -18,7 +18,6 @@ pub enum ErrorKind { MeloVariable(String), TypeError(String), TopLevelBreak, - ArithmeticError, BfInterpretError(InterpretError), MissingLhs, } diff --git a/src/interpret.rs b/src/interpret.rs index eb6bb2e..27dd2b1 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -19,7 +19,7 @@ use rand::random; use crate::{ ast::{Expr, Iden, Stmt, StmtKind}, - base_55, + base_55, consts, error::{Error, ErrorKind}, variables::{Functio, Value, Variable}, }; @@ -134,10 +134,7 @@ impl ExecEnv { Divide => lhs.checked_div(rhs), _ => unreachable!(), } - .ok_or(Error { - kind: ErrorKind::ArithmeticError, - span: expr.span.clone(), - })?; + .unwrap_or(consts::ANSWER); Int(res) }