Make arithmetic errors evaluate to 42
This commit is contained in:
parent
083eb01282
commit
ede6eccc71
|
@ -18,7 +18,6 @@ pub enum ErrorKind {
|
||||||
MeloVariable(String),
|
MeloVariable(String),
|
||||||
TypeError(String),
|
TypeError(String),
|
||||||
TopLevelBreak,
|
TopLevelBreak,
|
||||||
ArithmeticError,
|
|
||||||
BfInterpretError(InterpretError),
|
BfInterpretError(InterpretError),
|
||||||
MissingLhs,
|
MissingLhs,
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ use rand::random;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Expr, Iden, Stmt, StmtKind},
|
ast::{Expr, Iden, Stmt, StmtKind},
|
||||||
base_55,
|
base_55, consts,
|
||||||
error::{Error, ErrorKind},
|
error::{Error, ErrorKind},
|
||||||
variables::{Functio, Value, Variable},
|
variables::{Functio, Value, Variable},
|
||||||
};
|
};
|
||||||
|
@ -134,10 +134,7 @@ impl ExecEnv {
|
||||||
Divide => lhs.checked_div(rhs),
|
Divide => lhs.checked_div(rhs),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
.ok_or(Error {
|
.unwrap_or(consts::ANSWER);
|
||||||
kind: ErrorKind::ArithmeticError,
|
|
||||||
span: expr.span.clone(),
|
|
||||||
})?;
|
|
||||||
Int(res)
|
Int(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue