diff options
Diffstat (limited to 'src/type/display.rs')
-rw-r--r-- | src/type/display.rs | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/type/display.rs b/src/type/display.rs index ded97a0..758fee4 100644 --- a/src/type/display.rs +++ b/src/type/display.rs @@ -1,6 +1,6 @@ use std::fmt; -use crate::r#type::{Type, TypeError, Type::*, TypeError::*}; +use crate::r#type::{Type, TypeError, FunDefError, Type::*, TypeError::*, FunDefError::*}; impl fmt::Display for Type { @@ -113,8 +113,45 @@ impl fmt::Display for TypeError { ) }, FunAsAtom => write!(f, "'fn' used as atom doesn't make sense"), + InvalidFunDef(exp, err) => write!(f, "invalid function definition '{exp}': {err}"), OtherError => write!(f, "uncategorized error"), } } } + +impl fmt::Display for FunDefError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + NoFunToken => + write!( + f, + "no '{}'-token at start of definition", + crate::sexp::SLeaf::Fun + ), + NoArgumentList => + write!( + f, + "no list of argument names" + ), + NoTypeList => + write!( + f, + "no list of argument types" + ), + NoReturnType => + write!( + f, + "no return type supplied" + ), + NoFunctionBody => + write!( + f, + "function has no body" + ), + InvalidArgumentList => write!(f, "invalid argument list"), + InvalidTypeList => write!(f, "invalid argument type list"), + InvalidReturnType => write!(f, "invalid return type"), + } + } +} |