Unification works with bad annotations

This commit is contained in:
greg 2019-02-10 07:32:12 -08:00
parent 42a801d346
commit 5e1799268d
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,5 @@
use std::rc::Rc;
use std::collections::HashMap;
use std::fmt;
use crate::tokenizing::TokenKind;
use crate::typechecking::{TypeConst, Type};

View File

@ -28,7 +28,7 @@ pub enum Type {
Arrow(Box<Type>, Box<Type>)
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub enum TypeConst {
Unit,
Nat,
@ -224,7 +224,10 @@ impl<'a> TypeContext<'a> {
fn unify(&mut self, t1: Type, t2: Type) -> InferResult<Type> {
println!("Unify ain't done yo");
Ok(t1)
use self::Type::*; use self::TypeConst::*;
Ok(match (t1, t2) {
(Const(ref c1), Const(ref c2)) if c1 == c2 => Const(c1.clone()), //choice of c1 is arbitrary I *think*
(a, b) => return TypeError::new(&format!("{:?} and {:?} do not unify", a, b)),
})
}
}