Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
derarion committed Jul 12, 2024
1 parent f90d1d4 commit 9584b46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions momonga/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum JumpStmt<'a> {
Error(EvalError),
}

const MAX_ABS_INT: u64 = std::i64::MIN.unsigned_abs(); // TODO: Reconsider how to handle value overflow
const MAX_ABS_INT: u64 = i64::MIN.unsigned_abs(); // TODO: Reconsider how to handle value overflow

pub fn eval<'a>(
program: &'a Program,
Expand All @@ -40,7 +40,7 @@ fn eval_block_stmt<'a>(block_stmt: &'a BlockStmt, env: Rc<RefCell<Env<'a>>>) ->
Stmt::FuncDecl(func_decl) => eval_func_decl(func_decl, Rc::clone(&env_block)),
Stmt::IfStmt(if_stmt) => eval_if_stmt(if_stmt, Rc::clone(&env_block)),
Stmt::ForStmt(for_stmt) => eval_for_stmt(for_stmt, Rc::clone(&env_block)),
Stmt::WhileStmt(while_stmt) => todo!(),
Stmt::WhileStmt(_while_stmt) => todo!(),
Stmt::VarStmt(var_stmt) => eval_var_stmt(var_stmt, Rc::clone(&env_block)),
Stmt::ExprStmt(expr_stmt) => eval_expr_stmt(expr_stmt, Rc::clone(&env_block)),
Stmt::ContinueStmt => Err(JumpStmt::Continue),
Expand Down Expand Up @@ -214,12 +214,12 @@ fn eval_expr<'a>(expr: &'a Expr, env: Rc<RefCell<Env<'a>>>) -> EvalExprResult<'a
PrefixOpKind::Neg => {
if let Expr::Literal(Literal::Int(int)) = **rhs {
if int == MAX_ABS_INT {
return Ok(Rc::new(RefCell::new(Value::Int(std::i64::MIN))));
return Ok(Rc::new(RefCell::new(Value::Int(i64::MIN))));
};
};
match *eval_expr(rhs, env)?.borrow() {
Value::Int(int) => {
if int == std::i64::MIN {
if int == i64::MIN {
return Err(JumpStmt::Error(EvalError::OutOfRange));
// Attempt to nagate i64 min
}
Expand Down
4 changes: 2 additions & 2 deletions momonga/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn prefix_operator_is_interpreted_correctly() {
r#"
-9223372036854775808; // Min value of Integer type
"#,
Some(std::i64::MIN.to_string()),
Some(i64::MIN.to_string()),
),
(
r#"
Expand All @@ -153,7 +153,7 @@ fn prefix_operator_is_interpreted_correctly() {
r#"
+-9223372036854775808; // Attempt to apply + operator to the min of Integer type
"#,
Some(std::i64::MIN.to_string()),
Some(i64::MIN.to_string()),
),
(
r#"
Expand Down

0 comments on commit 9584b46

Please sign in to comment.