Got typechecker unused errors down to one
This commit is contained in:
parent
7c46a29141
commit
955c073174
@ -60,7 +60,7 @@ impl Type<TVar> {
|
|||||||
fn skolemize(&self) -> Type<UVar> {
|
fn skolemize(&self) -> Type<UVar> {
|
||||||
match self {
|
match self {
|
||||||
Type::Var(TVar::Univ(uvar)) => Type::Var(uvar.clone()),
|
Type::Var(TVar::Univ(uvar)) => Type::Var(uvar.clone()),
|
||||||
Type::Var(TVar::Exist(evar)) => Type::Var(UVar(Rc::new(format!("sk")))),
|
Type::Var(TVar::Exist(_)) => Type::Var(UVar(Rc::new(format!("sk")))),
|
||||||
Type::Const(ref c) => Type::Const(c.clone()),
|
Type::Const(ref c) => Type::Const(c.clone()),
|
||||||
Type::Arrow(a, b) => Type::Arrow(
|
Type::Arrow(a, b) => Type::Arrow(
|
||||||
Box::new(a.skolemize()),
|
Box::new(a.skolemize()),
|
||||||
@ -73,7 +73,7 @@ impl Type<TVar> {
|
|||||||
impl TypeIdentifier {
|
impl TypeIdentifier {
|
||||||
fn to_monotype(&self) -> Type<UVar> {
|
fn to_monotype(&self) -> Type<UVar> {
|
||||||
match self {
|
match self {
|
||||||
TypeIdentifier::Tuple(items) => unimplemented!(),
|
TypeIdentifier::Tuple(_) => Type::Const(TConst::Nat),
|
||||||
TypeIdentifier::Singleton(TypeSingletonName { name, .. }) => {
|
TypeIdentifier::Singleton(TypeSingletonName { name, .. }) => {
|
||||||
match &name[..] {
|
match &name[..] {
|
||||||
"Nat" => Type::Const(TConst::Nat),
|
"Nat" => Type::Const(TConst::Nat),
|
||||||
@ -81,7 +81,7 @@ impl TypeIdentifier {
|
|||||||
"Float" => Type::Const(TConst::Float),
|
"Float" => Type::Const(TConst::Float),
|
||||||
"Bool" => Type::Const(TConst::Bool),
|
"Bool" => Type::Const(TConst::Bool),
|
||||||
"String" => Type::Const(TConst::StringT),
|
"String" => Type::Const(TConst::StringT),
|
||||||
_ => unimplemented!()
|
_ => Type::Const(TConst::Nat),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,12 +105,6 @@ impl TConst {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct PolyType {
|
|
||||||
vars: Vec<Rc<String>>,
|
|
||||||
ty: Type<()>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> TypeContext<'a> {
|
impl<'a> TypeContext<'a> {
|
||||||
pub fn new() -> TypeContext<'a> {
|
pub fn new() -> TypeContext<'a> {
|
||||||
TypeContext {
|
TypeContext {
|
||||||
@ -129,11 +123,7 @@ impl<'a> TypeContext<'a> {
|
|||||||
|
|
||||||
impl<'a> TypeContext<'a> {
|
impl<'a> TypeContext<'a> {
|
||||||
fn infer_ast(&mut self, ast: &AST) -> InferResult<Type<UVar>> {
|
fn infer_ast(&mut self, ast: &AST) -> InferResult<Type<UVar>> {
|
||||||
let mut output = Type::Const(TConst::Unit);
|
self.infer_block(&ast.0)
|
||||||
for statement in ast.0.iter() {
|
|
||||||
output = self.infer_statement(statement)?;
|
|
||||||
}
|
|
||||||
Ok(output)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_statement(&mut self, stmt: &Statement) -> InferResult<Type<UVar>> {
|
fn infer_statement(&mut self, stmt: &Statement) -> InferResult<Type<UVar>> {
|
||||||
@ -154,7 +144,7 @@ impl<'a> TypeContext<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_decl(&mut self, expr: &Declaration) -> InferResult<Type<UVar>> {
|
fn infer_decl(&mut self, _decl: &Declaration) -> InferResult<Type<UVar>> {
|
||||||
Ok(Type::Const(TConst::user("unimplemented")))
|
Ok(Type::Const(TConst::user("unimplemented")))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,29 +176,33 @@ impl<'a> TypeContext<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Lambda { params, type_anno, body } => {
|
Lambda { params, .. } => {
|
||||||
|
|
||||||
let arg_type = unimplemented!();
|
let _arg_type = match ¶ms[0] {
|
||||||
let result_type = unimplemented!();
|
(_, Some(type_anno)) => type_anno.to_monotype().to_tvar(),
|
||||||
|
(_, None) => self.allocate_existential(),
|
||||||
|
};
|
||||||
|
//let _result_type = unimplemented!();
|
||||||
|
return TypeError::new("Unimplemented");
|
||||||
|
|
||||||
Type::Arrow(Box::new(arg_type), Box::new(result_type))
|
//Type::Arrow(Box::new(arg_type), Box::new(result_type))
|
||||||
}
|
}
|
||||||
_ => Type::Const(TConst::user("unimplemented"))
|
_ => Type::Const(TConst::user("unimplemented"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_if_expr(&mut self, discriminator: &Discriminator, body: &IfExpressionBody) -> InferResult<Type<UVar>> {
|
fn infer_if_expr(&mut self, discriminator: &Discriminator, body: &IfExpressionBody) -> InferResult<Type<UVar>> {
|
||||||
let test = match discriminator {
|
let _test = match discriminator {
|
||||||
Discriminator::Simple(expr) => expr,
|
Discriminator::Simple(expr) => expr,
|
||||||
_ => return TypeError::new("Dame desu")
|
_ => return TypeError::new("Dame desu")
|
||||||
};
|
};
|
||||||
|
|
||||||
let (then_clause, maybe_else_clause) = match body {
|
let (_then_clause, _maybe_else_clause) = match body {
|
||||||
IfExpressionBody::SimpleConditional(a, b) => (a, b),
|
IfExpressionBody::SimpleConditional(a, b) => (a, b),
|
||||||
_ => return TypeError::new("Dont work")
|
_ => return TypeError::new("Dont work")
|
||||||
};
|
};
|
||||||
|
|
||||||
unimplemented!()
|
TypeError::new("Not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_block(&mut self, block: &Block) -> InferResult<Type<UVar>> {
|
fn infer_block(&mut self, block: &Block) -> InferResult<Type<UVar>> {
|
||||||
@ -219,8 +213,8 @@ impl<'a> TypeContext<'a> {
|
|||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unify(&mut self, t1: &Type<TVar>, t2: &Type<TVar>) -> InferResult<Type<TVar>> {
|
fn unify(&mut self, _t1: &Type<TVar>, _t2: &Type<TVar>) -> InferResult<Type<TVar>> {
|
||||||
unimplemented!()
|
TypeError::new("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocate_existential(&mut self) -> Type<TVar> {
|
fn allocate_existential(&mut self) -> Type<TVar> {
|
||||||
|
Loading…
Reference in New Issue
Block a user