Unification works with bad annotations
This commit is contained in:
parent
42a801d346
commit
5e1799268d
@ -1,6 +1,5 @@
|
||||
use std::rc::Rc;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
||||
use crate::tokenizing::TokenKind;
|
||||
use crate::typechecking::{TypeConst, Type};
|
||||
|
@ -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)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user