Checkpoint

This commit is contained in:
2023-10-14 16:39:16 -07:00
parent 87d027bf8d
commit 71228b9e09
18 changed files with 402 additions and 78 deletions

View File

@@ -46,6 +46,8 @@ pub use value::Value;
use crate::backend::BackendError;
use self::primtype::UnknownPrimType;
/// All of the errors that can happen trying to evaluate an NGR program.
///
/// This is yet another standard [`thiserror::Error`] type, but with the
@@ -71,9 +73,13 @@ pub enum EvalError {
ExitCode(std::process::ExitStatus),
#[error("Unexpected output at runtime: {0}")]
RuntimeOutput(String),
#[error("Cannot cast to function type: {0}")]
CastToFunction(String),
#[error(transparent)]
UnknownPrimType(#[from] UnknownPrimType),
}
impl PartialEq for EvalError {
impl PartialEq<EvalError> for EvalError {
fn eq(&self, other: &Self) -> bool {
match self {
EvalError::Lookup(a) => match other {
@@ -115,6 +121,16 @@ impl PartialEq for EvalError {
EvalError::RuntimeOutput(b) => a == b,
_ => false,
},
EvalError::CastToFunction(a) => match other {
EvalError::CastToFunction(b) => a == b,
_ => false,
},
EvalError::UnknownPrimType(a) => match other {
EvalError::UnknownPrimType(b) => a == b,
_ => false,
},
}
}
}