aboutsummaryrefslogtreecommitdiff
path: root/src/type/display.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/type/display.rs')
-rw-r--r--src/type/display.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/type/display.rs b/src/type/display.rs
index 758fee4..e945eba 100644
--- a/src/type/display.rs
+++ b/src/type/display.rs
@@ -1,6 +1,15 @@
use std::fmt;
-use crate::r#type::{Type, TypeError, FunDefError, Type::*, TypeError::*, FunDefError::*};
+use crate::r#type::{
+ Type,
+ TypeError,
+ FunDefError,
+ PatFail,
+ Type::*,
+ TypeError::*,
+ FunDefError::*,
+ PatFail::*
+};
impl fmt::Display for Type {
@@ -98,6 +107,7 @@ impl fmt::Display for TypeError {
arglist, expected, found
)
},
+ InvalidPattern(ty) => write!(f, "invalid pattern: {ty}"),
ArgumentsDontMatchGeneric { argtype, generictype } => {
write!(
f,
@@ -120,6 +130,23 @@ impl fmt::Display for TypeError {
}
+impl fmt::Display for PatFail {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ RepeatedVariable(name, exp_in) =>
+ write!(f, "repeated pattern variable '{name}' in '{exp_in}'"),
+ TypeMismatch { pattern, expected, found } =>
+ write!(
+ f,
+ "type mismatch in '{}' — expected type '{}', found '{}'",
+ pattern,
+ expected,
+ found,
+ ),
+ }
+ }
+}
+
impl fmt::Display for FunDefError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {