Explorar el Código

Amélioration évaluation

Arthur Brandao hace 6 años
padre
commit
a6f31a5a6b
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      src/migl/lisp/LispImpl.java

+ 3 - 0
src/migl/lisp/LispImpl.java

@@ -253,6 +253,9 @@ public class LispImpl implements Lisp {
 			}
 			LispElement elt1 = getElement(lisp.car());
 			LispElement elt2 = getElement(lisp.cdr().car());
+			if(elt2.toNumber() == 0) {
+				throw new LispError("Division by zero");
+			}
 			if(elt1.value.getClass() == Double.class || elt2.value.getClass() == Double.class) {
 				return LispElement.generate(elt1.toNumber() / elt2.toNumber());
 			}