Skip to content

Commit 48e7b05

Browse files
authored
Merge pull request #66 from britzl/fix-64-divexpression-zero
Do not simplify DivExpression if dividing with 0
2 parents 591c8ab + 7318676 commit 48e7b05

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/prometheus/ast.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ function Ast.MulExpression(lhs, rhs, simplify)
627627
end
628628

629629
function Ast.DivExpression(lhs, rhs, simplify)
630-
if(simplify and rhs.isConstant and lhs.isConstant) then
630+
if(simplify and rhs.isConstant and lhs.isConstant and rhs.value ~= 0) then
631631
local success, val = pcall(function() return lhs.value / rhs.value end);
632632
if success then
633633
return Ast.ConstantNode(val);

0 commit comments

Comments
 (0)