More typechecking infrastructure

This commit is contained in:
greg 2018-11-06 16:47:34 -08:00
parent 15f9dbe7a6
commit 020819550b

View File

@ -1,6 +1,6 @@
use std::rc::Rc; use std::rc::Rc;
use ast::AST; use ast::*;
pub type TypeName = Rc<String>; pub type TypeName = Rc<String>;
@ -8,12 +8,39 @@ pub struct TypeContext {
} }
type TypeResult<T> = Result<T, TypeError>;
#[derive(Debug, Clone)]
struct TypeError { }
struct Type {
}
impl TypeContext { impl TypeContext {
pub fn new() -> TypeContext { pub fn new() -> TypeContext {
TypeContext { } TypeContext { }
} }
pub fn typecheck(&mut self, _ast: &AST) -> Result<(), String> { pub fn typecheck(&mut self, ast: &AST) -> Result<(), String> {
Ok(()) match self.infer_ast(ast) {
Ok(_) => Ok(()),
Err(err) => Err(format!("Type error: {:?}", err))
}
}
}
impl TypeContext {
fn infer_ast(&mut self, ast: &AST) -> TypeResult<()> {
unimplemented!()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn basic_inference() {
} }
} }