aboutsummaryrefslogtreecommitdiff
path: root/src/type/check.rs
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-14 16:07:46 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-14 17:28:04 +0300
commite85dae567589181959683f78a783b6a81fb3d01f (patch)
tree9c5831c4429b2458936cbb9122f4a954543672f0 /src/type/check.rs
parent540a84fb9288699b534e98c8c5d0e649aaa1c2ba (diff)
downloadmyslip-e85dae567589181959683f78a783b6a81fb3d01f.tar.gz
myslip-e85dae567589181959683f78a783b6a81fb3d01f.zip
test: stricter generic checking tests added for Type::aka and Type::into_type
Diffstat (limited to 'src/type/check.rs')
-rw-r--r--src/type/check.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/type/check.rs b/src/type/check.rs
index 2c04d2e..effdc0a 100644
--- a/src/type/check.rs
+++ b/src/type/check.rs
@@ -220,7 +220,7 @@ impl SExp {
match res {
Ok(res) => match res.is_concrete() {
Ok(()) => Ok(res),
- Err(name) => Err(UnboundGeneric(name)),
+ Err(name) => Err(UnboundGeneric(name, res)),
},
e => e,
}
@@ -338,10 +338,6 @@ impl SExp {
let opertype = (*op).infer_type(ctx.clone())?;
let argstype = (*l).infer_list_type(ctx)?;
- if opertype == TypeLit && argstype.aka(&vecof(TypeLit)) {
- return Ok(TypeLit);
- }
-
let conv_args = match (opertype.clone(), argstype.clone()) {
(Arrow(from, _), a) => match a.clone().into_type(&*from) {
Ok(s) => Ok(s),
@@ -429,7 +425,7 @@ impl Type {
match restype.is_concrete() {
Ok(()) => Ok(arr(argtype.clone(), restype)),
- Err(unbound) => Err(UnboundGeneric(unbound)),
+ Err(unbound) => Err(UnboundGeneric(unbound, self.clone())),
}
},
_ => Err(OtherError)
@@ -490,9 +486,8 @@ mod tests {
#[test]
fn test_failing_infer_generics() {
- assert_eq!(
- arr(Integer, VarType("X".to_string())).infer_generics(&Integer),
- Err(TypeError::UnboundGeneric(String::from("X")))
+ assert!(
+ arr(Integer, VarType("X".to_string())).infer_generics(&Integer).is_err()
);
}