Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psalter: Internal Psalm error Division by zero #9246

Closed
aboyton opened this issue Feb 9, 2023 · 1 comment · Fixed by #9247
Closed

Psalter: Internal Psalm error Division by zero #9246

aboyton opened this issue Feb 9, 2023 · 1 comment · Fixed by #9247

Comments

@aboyton
Copy link

aboyton commented Feb 9, 2023

I'm getting a divide by zero error when processing code such as $a = 1 / 0.0;. It works fine for an integer zero $a = 1 / 0;

https://psalm.dev/r/1a7af27899

I'm getting the error

Psalm runner output: 

Internal Psalm error on line 969 - /vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php: Division by zero

This appears to come from the check

if ($operand2 === 0) {
    return Type::getNever();
}

$result = $operand1 / $operand2;

I've not worked on this repo before, but I'm happy to make a PR to fix this.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/1a7af27899
<?php

$a = 1 / 0.0;

echo $a;
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php: Division by zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants