aboutsummaryrefslogtreecommitdiff
path: root/src/type/check.rs
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-09 21:18:48 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-09 21:18:48 +0300
commit8062ed87d30fa7628f26cfd7bb94bb0e7401752b (patch)
tree706bf5e34678622111a23c7045f667c1acbe7c6d /src/type/check.rs
parent3e1bf7f9946efe70d452c71494ac77ed39110804 (diff)
downloadmyslip-8062ed87d30fa7628f26cfd7bb94bb0e7401752b.tar.gz
myslip-8062ed87d30fa7628f26cfd7bb94bb0e7401752b.zip
Revert adding of print (its behavior was poorly designed).
This reverts commit 3e1bf7f9946efe70d452c71494ac77ed39110804.
Diffstat (limited to 'src/type/check.rs')
-rw-r--r--src/type/check.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/type/check.rs b/src/type/check.rs
index 91ca422..e536ce7 100644
--- a/src/type/check.rs
+++ b/src/type/check.rs
@@ -163,11 +163,7 @@ impl SExp {
/// };
/// ```
pub fn type_check(&self) -> Result<Type, TypeError> {
- let ty = self.infer_type(HashMap::new())?;
- match ty.is_concrete() {
- Ok(()) => Ok(ty),
- Err(s) => Err(UnboundGeneric(ty, s)),
- }
+ self.infer_type(HashMap::new())
}
@@ -198,7 +194,6 @@ 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) => {
@@ -303,11 +298,10 @@ impl Type {
restype = restype.subst(&name, &ty);
}
- //match restype.is_concrete() {
- // Ok(()) => Ok(arr(argtype.clone(), restype)),
- // Err(unbound) => Err(UnboundGeneric(unbound)),
- //}
- Ok(arr(argtype.clone(), restype))
+ match restype.is_concrete() {
+ Ok(()) => Ok(arr(argtype.clone(), restype)),
+ Err(unbound) => Err(UnboundGeneric(unbound)),
+ }
},
_ => Err(OtherError)
}
@@ -385,6 +379,14 @@ 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