diff --git a/src/error/display.rs b/src/error/display.rs index 836ff4b..47f4993 100644 --- a/src/error/display.rs +++ b/src/error/display.rs @@ -62,6 +62,11 @@ impl fmt::Display for EvalexprError { TypeError { expected, actual } => { write!(f, "Expected one of {:?}, but got {:?}.", expected, actual) }, + WrongTypeCombination { operator, actual } => write!( + f, + "The operator {:?} was called with a wrong combination of types: {:?}", + operator, actual + ), UnmatchedLBrace => write!(f, "Found an unmatched opening parenthesis '('."), UnmatchedRBrace => write!(f, "Found an unmatched closing parenthesis ')'."), UnmatchedPartialToken { first, second } => { diff --git a/src/error/mod.rs b/src/error/mod.rs index 359dcec..55e84cc 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -7,7 +7,7 @@ use crate::{token::PartialToken, value::value_type::ValueType}; -use crate::value::Value; +use crate::{operator::Operator, value::Value}; mod display; @@ -112,6 +112,14 @@ pub enum EvalexprError { actual: Value, }, + /// An operator is used with a wrong combination of types. + WrongTypeCombination { + /// The operator that whose evaluation caused the error. + operator: Operator, + /// The types that were used in the operator causing it to fail. + actual: Vec, + }, + /// An opening brace without a matching closing brace was found. UnmatchedLBrace,