aboutsummaryrefslogtreecommitdiff
path: root/src/type/check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/type/check.rs')
-rw-r--r--src/type/check.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/type/check.rs b/src/type/check.rs
index 7a2d231..f842b4c 100644
--- a/src/type/check.rs
+++ b/src/type/check.rs
@@ -216,7 +216,14 @@ impl SExp {
/// };
/// ```
pub fn type_check(&self) -> Result<Type, TypeError> {
- self.infer_type(HashMap::new())
+ let res = self.infer_type(HashMap::new());
+ match res {
+ Ok(res) => match res.is_concrete() {
+ Ok(()) => Ok(res),
+ Err(name) => Err(UnboundGeneric(name)),
+ },
+ e => e,
+ }
}
@@ -305,10 +312,7 @@ impl SExp {
}
match &ty {
None => ty = Some(arm.infer_type(newctx)?),
- Some(t) => if arm.infer_type(newctx.clone())? != *t {
- println!("different types: {}, {}", t, arm.infer_list_type(newctx)?);
- return Err(OtherError);
- },
+ Some(t) => ty = Some(t.least_general_supertype(&arm.infer_type(newctx.clone())?)),
}
}
if !has_wildcard {