From a8a4c5b567ea6a58809dc8232ea5f1d3c93879b9 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 12 Aug 2025 20:00:56 +0300 Subject: feat: type checking for case expressions --- src/type/display.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/type/display.rs') diff --git a/src/type/display.rs b/src/type/display.rs index e945eba..290e24e 100644 --- a/src/type/display.rs +++ b/src/type/display.rs @@ -123,7 +123,10 @@ impl fmt::Display for TypeError { ) }, FunAsAtom => write!(f, "'fn' used as atom doesn't make sense"), + CaseAsAtom => write!(f, "'case' used as atom doesn't make sense"), + RestAsAtom => write!(f, "'..[name]' used as atom doesn't make sense"), InvalidFunDef(exp, err) => write!(f, "invalid function definition '{exp}': {err}"), + NoWildcardInCase(exp) => write!(f, "no wildcard in cases: '{exp}'"), OtherError => write!(f, "uncategorized error"), } } @@ -133,6 +136,10 @@ impl fmt::Display for TypeError { impl fmt::Display for PatFail { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + RestNotAtEnd(exp) => + write!(f, "rest pattern should be at end in '{exp}'"), + NoArm(exp) => + write!(f, "'{exp}' should consist of a pattern and a respective arm"), RepeatedVariable(name, exp_in) => write!(f, "repeated pattern variable '{name}' in '{exp_in}'"), TypeMismatch { pattern, expected, found } => -- cgit v1.2.3