ran into another type inference problem

This commit is contained in:
2024-02-05 17:30:16 -06:00
parent 7def938781
commit 9d41cf0da7
17 changed files with 267 additions and 24 deletions

View File

@@ -39,6 +39,7 @@ mod primtype;
mod value;
use cranelift_module::ModuleError;
use internment::ArcIntern;
pub use primop::PrimOpError;
pub use primtype::PrimitiveType;
pub use value::Value;
@@ -76,6 +77,15 @@ pub enum EvalError<IR> {
UnknownPrimType(#[from] UnknownPrimType),
#[error("Variable lookup failed for {1} at {0:?}")]
LookupFailed(crate::syntax::Location, String),
#[error("Attempted to call something that wasn't a function at {0:?} (it was a {1})")]
NotAFunction(crate::syntax::Location, Value<IR>),
#[error("Wrong argument call for function ({1:?}) at {0:?}; expected {2}, saw {3}")]
WrongArgCount(
crate::syntax::Location,
Option<ArcIntern<String>>,
usize,
usize,
),
}
impl<IR1: Clone, IR2: Clone> PartialEq<EvalError<IR1>> for EvalError<IR2> {
@@ -129,6 +139,16 @@ impl<IR1: Clone, IR2: Clone> PartialEq<EvalError<IR1>> for EvalError<IR2> {
EvalError::UnknownPrimType(b) => a == b,
_ => false,
},
EvalError::NotAFunction(a, b) => match other {
EvalError::NotAFunction(x, y) => a == x && b == y,
_ => false,
},
EvalError::WrongArgCount(a, b, c, d) => match other {
EvalError::WrongArgCount(w, x, y, z) => a == w && b == x && c == y && d == z,
_ => false,
},
}
}
}