From 4009dc50cfab951a0557f40b05f6183f4c6c5979 Mon Sep 17 00:00:00 2001 From: Martin Hansen Date: Fri, 24 Mar 2023 14:20:27 +0100 Subject: [PATCH 1/2] Refactor unary minus --- checkr/src/interpreter.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/checkr/src/interpreter.rs b/checkr/src/interpreter.rs index e9d4d459..f13d8db8 100644 --- a/checkr/src/interpreter.rs +++ b/checkr/src/interpreter.rs @@ -151,9 +151,7 @@ impl AExpr { } } AExpr::Binary(l, op, r) => op.semantic(l.semantics(m)?, r.semantics(m)?)?, - AExpr::Minus(n) => { - (n.semantics(m)?).checked_neg().ok_or(InterpreterError::ArithmeticOverflow)? - } + AExpr::Minus(n) => (n.semantics(m)?).checked_neg().ok_or(InterpreterError::ArithmeticOverflow)?, AExpr::Function(f) => return Err(todo!("evaluating functions {f}")), }) } From 2a44a6e62dd3d932e1a7919dde167c74fc8e83c5 Mon Sep 17 00:00:00 2001 From: Martin Hansen Date: Fri, 24 Mar 2023 14:25:24 +0100 Subject: [PATCH 2/2] fmt applied to interpreter --- checkr/src/interpreter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/checkr/src/interpreter.rs b/checkr/src/interpreter.rs index f13d8db8..c436ef85 100644 --- a/checkr/src/interpreter.rs +++ b/checkr/src/interpreter.rs @@ -151,7 +151,9 @@ impl AExpr { } } AExpr::Binary(l, op, r) => op.semantic(l.semantics(m)?, r.semantics(m)?)?, - AExpr::Minus(n) => (n.semantics(m)?).checked_neg().ok_or(InterpreterError::ArithmeticOverflow)?, + AExpr::Minus(n) => (n.semantics(m)?) + .checked_neg() + .ok_or(InterpreterError::ArithmeticOverflow)?, AExpr::Function(f) => return Err(todo!("evaluating functions {f}")), }) }