File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -101,12 +101,21 @@ std::unique_ptr<NodeResult> ArithmeticOperationNode::evaluate(PSC::Context &ctx)
101101 resNum = leftNum * rightNum;
102102 break ;
103103 case TokenType::SLASH:
104+ if ((rightNum.real && ((PSC::Real&) rightNum).value == 0 )
105+ || (!rightNum.real && ((PSC::Integer&) rightNum).value == 0 )
106+ ) throw PSC::RuntimeError (token, ctx, " Division by 0" );
104107 resNum = leftNum / rightNum;
105108 break ;
106109 case TokenType::MOD:
110+ if ((rightNum.real && ((PSC::Real&) rightNum).value == 0 )
111+ || (!rightNum.real && ((PSC::Integer&) rightNum).value == 0 )
112+ ) throw PSC::RuntimeError (token, ctx, " Modulus by 0" );
107113 resNum = leftNum % rightNum;
108114 break ;
109115 case TokenType::DIV:
116+ if ((rightNum.real && ((PSC::Real&) rightNum).value == 0 )
117+ || (!rightNum.real && ((PSC::Integer&) rightNum).value == 0 )
118+ ) throw PSC::RuntimeError (token, ctx, " Division by 0" );
110119 resNum = leftNum | rightNum;
111120 break ;
112121 default :
You can’t perform that action at this time.
0 commit comments