From 0e2ca4a489200c3da5cb22077200f7bee4f0382b Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 29 Aug 2019 13:49:56 +0300 Subject: [PATCH] Add but not use WrongTypeCombinationError Relates to #60 --- src/error/display.rs | 5 +++++ src/error/mod.rs | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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,