More typechecking infrastructure

This commit is contained in:
greg 2018-11-06 16:47:34 -08:00
parent 15f9dbe7a6
commit 020819550b
1 changed files with 30 additions and 3 deletions

View File

@ -1,6 +1,6 @@
use std::rc::Rc;
use ast::AST;
use ast::*;
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 {
pub fn new() -> TypeContext {
TypeContext { }
}
pub fn typecheck(&mut self, _ast: &AST) -> Result<(), String> {
Ok(())
pub fn typecheck(&mut self, ast: &AST) -> Result<(), String> {
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() {
}
}