From 88c6600d05d5503141de88351b2f610bc59e1574 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Thu, 27 Apr 2023 21:09:29 -0700 Subject: [PATCH] A little more documentation on PrimOpError. --- src/eval/primop.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/eval/primop.rs b/src/eval/primop.rs index e60d39c..bdb518e 100644 --- a/src/eval/primop.rs +++ b/src/eval/primop.rs @@ -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}")]