diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-10 22:33:48 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-10 22:33:48 +0300 |
commit | 2f101372e3311f1ccf7f8ec093c7fde9f4373439 (patch) | |
tree | 209cac3d19bc9ee714eedd17766bdc939a1feefa /src/type/display.rs | |
parent | d6d1ec80ffcc0b13234b170a91b920371078a027 (diff) | |
download | myslip-2f101372e3311f1ccf7f8ec093c7fde9f4373439.tar.gz myslip-2f101372e3311f1ccf7f8ec093c7fde9f4373439.zip |
Implemented functions
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"), + } + } +} |