diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-06 17:05:55 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-06 17:05:55 +0300 |
commit | 3e1bf7f9946efe70d452c71494ac77ed39110804 (patch) | |
tree | f7682f538db9d8b77890e8c0e9c54eb2968d4388 /src/type/check.rs | |
parent | 313c044b4a878a425aaca6554576f5154ace8ff9 (diff) | |
download | myslip-3e1bf7f9946efe70d452c71494ac77ed39110804.tar.gz myslip-3e1bf7f9946efe70d452c71494ac77ed39110804.zip |
Added print, raised level on which UnboundGeneric error is returned
Diffstat (limited to 'src/type/check.rs')
-rw-r--r-- | src/type/check.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/type/check.rs b/src/type/check.rs index e536ce7..91ca422 100644 --- a/src/type/check.rs +++ b/src/type/check.rs @@ -163,7 +163,11 @@ impl SExp { /// }; /// ``` pub fn type_check(&self) -> Result<Type, TypeError> { - self.infer_type(HashMap::new()) + let ty = self.infer_type(HashMap::new())?; + match ty.is_concrete() { + Ok(()) => Ok(ty), + Err(s) => Err(UnboundGeneric(ty, s)), + } } @@ -194,6 +198,7 @@ impl SExp { List(vec![VecType, vecof(vt("T"))]) )), Atom(Let) => Ok(LetType), + Atom(Print) => Ok(arr(vt("_"), arr(vt("T"), vt("T")))), SCons(op, l) => { @@ -298,10 +303,11 @@ impl Type { restype = restype.subst(&name, &ty); } - match restype.is_concrete() { - Ok(()) => Ok(arr(argtype.clone(), restype)), - Err(unbound) => Err(UnboundGeneric(unbound)), - } + //match restype.is_concrete() { + // Ok(()) => Ok(arr(argtype.clone(), restype)), + // Err(unbound) => Err(UnboundGeneric(unbound)), + //} + Ok(arr(argtype.clone(), restype)) }, _ => Err(OtherError) } @@ -379,14 +385,6 @@ mod tests { use super::{*, TypeError}; #[test] - fn test_failing_infer_generics() { - assert_eq!( - arr(Integer, VarType("X".to_string())).infer_generics(&Integer), - Err(TypeError::UnboundGeneric(String::from("X"))) - ); - } - - #[test] fn test_infer_generics() { // Simple identity function, really all we |