From 5d976900d1c593e36976f436a59159b31fa234ef Mon Sep 17 00:00:00 2001 From: Andrew Boyton Date: Thu, 9 Feb 2023 11:55:06 +1100 Subject: [PATCH] Fix divide by a floating point zero The code was failing when dividing by 0.0. --- .../Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php index 1712c8a54..9be82c7c9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php @@ -962,7 +962,7 @@ class ArithmeticOpAnalyzer } elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\ShiftRight) { $result = $operand1 >> $operand2; } elseif ($operation instanceof PhpParser\Node\Expr\BinaryOp\Div) { - if ($operand2 === 0) { + if ($operand2 === 0 || $operand2 === 0.0) { return Type::getNever(); }