📜 Add better documentation across the compiler. #3
@@ -5,10 +5,19 @@ use crate::eval::value::Value;
|
|||||||
pub enum PrimOpError {
|
pub enum PrimOpError {
|
||||||
#[error("Math error (underflow or overflow) computing {0} operator")]
|
#[error("Math error (underflow or overflow) computing {0} operator")]
|
||||||
MathFailure(&'static str),
|
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")]
|
#[error("Type mismatch ({1} vs {2}) computing {0} operator")]
|
||||||
TypeMismatch(String, Value, Value),
|
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}")]
|
#[error("Bad type for operator {0}: {1}")]
|
||||||
BadTypeFor(&'static str, Value),
|
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")]
|
#[error("Illegal number of arguments for {0}: {1} arguments found")]
|
||||||
BadArgCount(String, usize),
|
BadArgCount(String, usize),
|
||||||
#[error("Unknown primitive operation {0}")]
|
#[error("Unknown primitive operation {0}")]
|
||||||
|
|||||||
Reference in New Issue
Block a user