A little more documentation on PrimOpError.

This commit is contained in:
2023-04-27 21:09:29 -07:00
parent c3b394d2c9
commit 88c6600d05

View File

@@ -5,10 +5,19 @@ use crate::eval::value::Value;
pub enum PrimOpError {
#[error("Math error (underflow or overflow) computing {0} operator")]
MathFailure(&'static str),
/// This particular variant covers the case in which a primitive
/// operator takes two arguments that are supposed to be the same,
/// but they differ. (So, like, all the math operators.)
#[error("Type mismatch ({1} vs {2}) computing {0} operator")]
TypeMismatch(String, Value, Value),
/// This variant covers when an operator must take a particular
/// type, but the user has provided a different one.
#[error("Bad type for operator {0}: {1}")]
BadTypeFor(&'static str, Value),
/// Probably obvious from the name, but just to be very clear: this
/// happens when you pass three arguments to a two argument operator,
/// etc. Technically that's a type error of some sort, but we split
/// it out.
#[error("Illegal number of arguments for {0}: {1} arguments found")]
BadArgCount(String, usize),
#[error("Unknown primitive operation {0}")]