diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-13 01:20:19 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-13 01:20:19 +0300 |
commit | 189d06730ae23770fbb970bf37eb0993edb8cd2d (patch) | |
tree | 73048265c57176ba27d2b823e09ebe4c1c7328c1 /src/type/check.rs | |
parent | ec13c45c8ae0f63fa715178308547cfadd8f8c39 (diff) | |
download | myslip-189d06730ae23770fbb970bf37eb0993edb8cd2d.tar.gz myslip-189d06730ae23770fbb970bf37eb0993edb8cd2d.zip |
feat: generic match arms, mostly for functions I guess?
Diffstat (limited to 'src/type/check.rs')
-rw-r--r-- | src/type/check.rs | 14 |
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 { |