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.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/type/check.rs b/src/type/check.rs
index a54ffc2..f1c4a2b 100644
--- a/src/type/check.rs
+++ b/src/type/check.rs
@@ -330,7 +330,9 @@ impl SExp {
}
match &ty {
None => ty = Some(arm.infer_type(newctx)?),
- Some(t) => ty = Some(t.least_general_supertype(&arm.infer_type(newctx.clone())?)),
+ Some(t) => if arm.infer_type(newctx)? != *t {
+ return Err(OtherError);
+ },
}
}
if !has_wildcard {
@@ -346,8 +348,15 @@ impl SExp {
let opertype = (*op).infer_type(ctx.clone())?;
let argstype = (*l).infer_list_type(ctx)?;
+ // makes [x] x
+ let argstype = match argstype {
+ List(v) if v.get(0).is_some() && v.get(1).is_none() =>
+ v.get(0).unwrap().clone(),
+ t => t,
+ };
+
let conv_args = match (opertype.clone(), argstype.clone()) {
- (Arrow(from, _), a) => match a.clone().into_type(&*from) {
+ (Arrow(from, _), a) => match a.clone().convert(&*from) {
Ok(s) => Ok(s),
Err(()) => Err(InvalidArgList {
arglist: (**l).clone(),
@@ -370,9 +379,9 @@ impl SExp {
opertype.infer_generics(&conv_args)?
};
- match (opertype, argstype) {
+ match (opertype, conv_args) {
(Arrow(a, b), c) => {
- if c.aka(&*a) {
+ if c == *a {
Ok(*b)
} else {
Err(InvalidArgList {