From fa1544c71f74b87a21a8eed015757771d7aa6a47 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 14 Aug 2019 07:31:59 -0700 Subject: [PATCH] Fix eval of negatives --- schala-lang/language/src/eval.rs | 6 ++++++ schala-lang/language/src/reduced_ast.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index d78ab62..7fcd636 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -529,6 +529,12 @@ mod eval_tests { */ } + #[test] + fn op_eval() { + test_in_fresh_env!("- 13", "-13"); + test_in_fresh_env!("10 - 2", "8"); + } + #[test] fn function_eval() { test_in_fresh_env!("fn oi(x) { x + 1 }; oi(4)", "5"); diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index e90a056..8b52bbf 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -450,7 +450,7 @@ impl BinOp { impl PrefixOp { fn reduce(&self, symbol_table: &SymbolTable, arg: &Box>) -> Expr { - match Builtin::from_str(self.sigil()).ok() { + match self.builtin { Some(op) => { let f = Box::new(Expr::Func(Func::BuiltIn(op))); Expr::Call { f, args: vec![arg.node().reduce(symbol_table)]}