Fix eval of negatives
This commit is contained in:
parent
fde169b623
commit
fa1544c71f
@ -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");
|
||||
|
@ -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)]}
|
||||
|
Loading…
Reference in New Issue
Block a user