Browse Source

Improved div by zero checks. Resolves #527

Brucey 5 years ago
parent
commit
7a657d4501
1 changed files with 4 additions and 0 deletions
  1. 4 0
      expr.bmx

+ 4 - 0
expr.bmx

@@ -1946,6 +1946,10 @@ Type TBinaryMathExpr Extends TBinaryExpr
 		End If
 		End If
 
 
 		If TConstExpr( lhs ) And TConstExpr( rhs ) Return EvalConst()
 		If TConstExpr( lhs ) And TConstExpr( rhs ) Return EvalConst()
+		
+		If TConstExpr( rhs ) And (op = "/" Or op = "mod") And TIntegralType(rhs.exprType) And Not Long(rhs.Eval()) Then
+			Err "Integer division by zero"
+		End If
 
 
 		Return Self
 		Return Self
 	End Method
 	End Method