diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2021-05-06 19:40:59 +0100 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2021-05-06 19:40:59 +0100 |
commit | dfc08ff2c6580bbeb3951b223e0332546ba3b0d9 (patch) | |
tree | 60597dd9492b9c2dfa10ea610289f143dd3e41b7 /src/chomp/ast/error.rs | |
parent | ef485d6f3e4df6e1a424ba3797388fa0bba6eb2e (diff) |
Introduce lambda expressions.
Diffstat (limited to 'src/chomp/ast/error.rs')
-rw-r--r-- | src/chomp/ast/error.rs | 22 |
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 {} |