summaryrefslogtreecommitdiff
path: root/src/chomp/ast/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/chomp/ast/error.rs')
-rw-r--r--src/chomp/ast/error.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/chomp/ast/error.rs b/src/chomp/ast/error.rs
index 9057ec3..ea145a7 100644
--- a/src/chomp/ast/error.rs
+++ b/src/chomp/ast/error.rs
@@ -6,31 +6,31 @@ use std::{
};
#[derive(Debug)]
-pub enum TranslateError {
+pub enum ReductionError {
CallNotAFunction {
on: Expression,
- span: Option<Span>,
+ span: Span,
},
WrongArgCount {
lambda: Lambda,
args: Vec<NamedExpression>,
- span: Option<Span>,
+ span: Span,
},
}
-impl From<TranslateError> for syn::Error {
- fn from(e: TranslateError) -> Self {
+impl From<ReductionError> for syn::Error {
+ fn from(e: ReductionError) -> Self {
let msg = e.to_string();
let span = match e {
- TranslateError::CallNotAFunction { span, .. }
- | TranslateError::WrongArgCount { span, .. } => span,
+ ReductionError::CallNotAFunction { span, .. }
+ | ReductionError::WrongArgCount { span, .. } => span,
};
- Self::new(span.unwrap_or_else(Span::call_site), msg)
+ Self::new(span, msg)
}
}
-impl Display for TranslateError {
+impl Display for ReductionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::CallNotAFunction { .. } => {
@@ -38,7 +38,7 @@ impl Display for TranslateError {
}
Self::WrongArgCount { lambda, args, .. } => match (lambda.args.len(), args.len()) {
(1, n) => write!(f, "this function takes 1 argument but {} were supplied", n),
- (m, _) => write!(f, "this function takes {} arguments but 1 was supplied", m),
+ (m, 1) => write!(f, "this function takes {} arguments but 1 was supplied", m),
(m, n) => write!(
f,
"this function takes {} arguments but {} were supplied",
@@ -49,4 +49,4 @@ impl Display for TranslateError {
}
}
-impl Error for TranslateError {}
+impl Error for ReductionError {}