aboutsummaryrefslogtreecommitdiff
path: root/src/lisp/number.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-03-25 07:38:25 +0000
committerAkshay <[email protected]>2021-03-25 07:38:25 +0000
commit8171b30adbc4cddd2c51f043c3379d78428666b8 (patch)
tree85e34bef77d330a5df52eef3bb2f249453329934 /src/lisp/number.rs
parent5a232822a25604e669740a803eea8d9889772d74 (diff)
use new error kinds; track Environment nesting with stack
Diffstat (limited to 'src/lisp/number.rs')
-rw-r--r--src/lisp/number.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lisp/number.rs b/src/lisp/number.rs
index 18a41f7..23d7997 100644
--- a/src/lisp/number.rs
+++ b/src/lisp/number.rs
@@ -1,9 +1,9 @@
1use std::{ 1use std::{
2 fmt, 2 fmt,
3 ops::{Add, Div, Mul, Sub}, 3 ops::{Add, Mul, Sub},
4}; 4};
5 5
6use crate::lisp::error::LispError; 6use crate::lisp::error::{EvalError, LispError};
7 7
8#[derive(Debug, Copy, Clone)] 8#[derive(Debug, Copy, Clone)]
9pub enum LispNumber { 9pub enum LispNumber {
@@ -15,7 +15,7 @@ impl LispNumber {
15 pub fn div(self, rhs: Self) -> Result<LispNumber, LispError> { 15 pub fn div(self, rhs: Self) -> Result<LispNumber, LispError> {
16 use LispNumber::*; 16 use LispNumber::*;
17 if rhs == Integer(0) || rhs == Float(0.) { 17 if rhs == Integer(0) || rhs == Float(0.) {
18 return Err(LispError::EvalError); 18 return Err(EvalError::DivByZero.into());
19 } else { 19 } else {
20 return Ok(match (self, rhs) { 20 return Ok(match (self, rhs) {
21 (Integer(a), Integer(b)) => Float(a as f64 / b as f64), 21 (Integer(a), Integer(b)) => Float(a as f64 / b as f64),