Add but not use WrongTypeCombinationError

Relates to #60
This commit is contained in:
Sebastian Schmidt 2019-08-29 13:49:56 +03:00
parent a3faefb893
commit 0e2ca4a489
2 changed files with 14 additions and 1 deletions

View File

@ -62,6 +62,11 @@ impl fmt::Display for EvalexprError {
TypeError { expected, actual } => { TypeError { expected, actual } => {
write!(f, "Expected one of {:?}, but got {:?}.", 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 '('."), UnmatchedLBrace => write!(f, "Found an unmatched opening parenthesis '('."),
UnmatchedRBrace => write!(f, "Found an unmatched closing parenthesis ')'."), UnmatchedRBrace => write!(f, "Found an unmatched closing parenthesis ')'."),
UnmatchedPartialToken { first, second } => { UnmatchedPartialToken { first, second } => {

View File

@ -7,7 +7,7 @@
use crate::{token::PartialToken, value::value_type::ValueType}; use crate::{token::PartialToken, value::value_type::ValueType};
use crate::value::Value; use crate::{operator::Operator, value::Value};
mod display; mod display;
@ -112,6 +112,14 @@ pub enum EvalexprError {
actual: Value, 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<ValueType>,
},
/// An opening brace without a matching closing brace was found. /// An opening brace without a matching closing brace was found.
UnmatchedLBrace, UnmatchedLBrace,