diff --git a/schala-lang/language/src/reduced_ir/test.rs b/schala-lang/language/src/reduced_ir/test.rs index 7b3c56c..3cd7197 100644 --- a/schala-lang/language/src/reduced_ir/test.rs +++ b/schala-lang/language/src/reduced_ir/test.rs @@ -38,5 +38,6 @@ fn test_ir() { "#; let reduced = build_ir(src); - assert!(1 == 2); + assert_eq!(reduced.functions.len(), 3); + //assert!(1 == 2); } diff --git a/schala-lang/language/src/tree_walk_eval/mod.rs b/schala-lang/language/src/tree_walk_eval/mod.rs index e8561ca..e6c3bc6 100644 --- a/schala-lang/language/src/tree_walk_eval/mod.rs +++ b/schala-lang/language/src/tree_walk_eval/mod.rs @@ -130,6 +130,12 @@ enum Primitive { */ } +impl Primitive { + fn unit() -> Self { + Primitive::Tuple(vec![]) + } +} + impl From for Primitive { fn from(lit: Literal) -> Self { Primitive::Literal(lit) @@ -240,9 +246,9 @@ impl<'a> State<'a> { }, Expression::Assign { ref lval, box rval } => { let mem = lval.into(); - let _ = rval; - let _env = self.environments.lookup(&mem); - return Err("Assign not implemented".into()); + let evaluated = self.expression(rval)?; + self.environments.insert(mem, RuntimeValue::Primitive(evaluated)); + Primitive::unit() }, Expression::Call { box f, args } => self.call_expression(f, args)?, Expression::Callable(func) => Primitive::Callable(func), diff --git a/schala-lang/language/src/tree_walk_eval/test.rs b/schala-lang/language/src/tree_walk_eval/test.rs index e919e37..d1bea6f 100644 --- a/schala-lang/language/src/tree_walk_eval/test.rs +++ b/schala-lang/language/src/tree_walk_eval/test.rs @@ -20,7 +20,7 @@ fn eval_assert(input: &str, expected: &str) { #[test] fn test_basic_eval() { eval_assert("1 + 2", "3"); - //eval_assert("let mut a = 1; a = 2", "()"); + eval_assert("let mut a = 1; a = 2", "()"); /* test_in_fresh_env!("let mut a = 1; a = 2; a", "2"); test_in_fresh_env!(r#"("a", 1 + 2)"#, r#"("a", 3)"#);