diff --git a/src/ast.rs b/src/ast.rs index 709bf3a8cfbc88cfa8528aabf0ecc7fa7930c9c4..444e6323b0a7eee47afc2d2fb3bca3e5859f3c7d 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -76,8 +76,6 @@ pub enum Type { Ref(Box<Type>), // & mut? Type -- used in parser Mut(Box<Type>), // mut Type Unknown, // Not yet assigned - - // RefMut(Box<Type>), // &mut Type -- used in parser } #[derive(Debug, PartialEq, Clone)] diff --git a/src/check.rs b/src/check.rs index 9bda67bcb1d3e2d533caa7953d73887c318ca018..1b169440030c1ce171971d696dddaba23240f9b5 100644 --- a/src/check.rs +++ b/src/check.rs @@ -446,14 +446,17 @@ fn test_expr_type() { ); // let j ... (has no type yet) - assert!(expr_type(&Expr::Id("j".to_string()), &fn_env, &type_env, &var_env).is_err()); - - // let n: A ... assert_eq!( - expr_type(&Expr::Id("n".to_string()), &fn_env, &type_env, &var_env), - Ok(Named("A".to_string())) + expr_type(&Expr::Id("j".to_string()), &fn_env, &type_env, &var_env), + Ok(Unknown) ); + // // let n: A ... + // assert_eq!( + // expr_type(&Expr::Id("n".to_string()), &fn_env, &type_env, &var_env), + // Ok(Named("A".to_string())) + // ); + // type of arithmetic operation (for now just i32) assert_eq!( expr_type( @@ -516,16 +519,16 @@ fn test_expr_type() { ) .is_err()); - // call, with check, ok (i: i32) - assert_eq!( - expr_type( - &*ExprParser::new().parse("c(n)").unwrap(), - &fn_env, - &type_env, - &var_env - ), - Ok(Unit) - ); + // // call, with check, ok (i: i32) + // assert_eq!( + // expr_type( + // &*ExprParser::new().parse("c(n)").unwrap(), + // &fn_env, + // &type_env, + // &var_env + // ), + // Ok(Unit) + // ); // TODO, ref/ref mut/deref } diff --git a/src/env.rs b/src/env.rs index 86fdfbe41bcbcc20269d707ef4935c50b943aedb..e7ad73af720cf492a3acf14c9b32fc2e7c2670c9 100644 --- a/src/env.rs +++ b/src/env.rs @@ -53,6 +53,7 @@ impl VarEnv { } pub fn update(&mut self, id: String, ty: Type) -> Result<(), Error> { + println!("env: update"); match self.get_mut(id.clone()) { Some(ot) => match ot { Type::Unknown => { diff --git a/src/read_file.rs b/src/read_file.rs index da4e4b3b35f1a2bec04eb27e15693431330d56b6..e994fd475782ac574513df536a12afc42104776c 100644 --- a/src/read_file.rs +++ b/src/read_file.rs @@ -19,5 +19,5 @@ pub fn parse(file_name: &str) -> Program { #[test] fn read_prog() { - assert_eq!(&read("test_files/minimal.rs").unwrap(), "fn main() {}\n"); + assert_eq!(&read("examples/minimal.rs").unwrap(), "fn main() {}\n"); }