Fix eval of negatives

This commit is contained in:
greg 2019-08-14 07:31:59 -07:00
parent fde169b623
commit fa1544c71f
2 changed files with 7 additions and 1 deletions

View File

@ -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");

View File

@ -450,7 +450,7 @@ impl BinOp {
impl PrefixOp {
fn reduce(&self, symbol_table: &SymbolTable, arg: &Box<Meta<Expression>>) -> 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)]}