-
Notifications
You must be signed in to change notification settings - Fork 677
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
PossiblyFalseOperand: false is not erased after > 0
comparison
#8745
Comments
I found these snippets: https://psalm.dev/r/72fd1e5782<?php
function formatVarchar(int|false $length): string
{
return $length > 0 ? 'VARCHAR(' . $length . ')' : 'VARCHAR';
}
|
Thanks for reporting! Given that you tested the beta, this would be a new regression in the RC, correct? |
This happened on a different codebase than I tested the beta on. I can't tell whether the beta was affected already, sorry. |
Thank you for the quick bugfix! 🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found while testing 5.0.0-rc1
https://psalm.dev/r/72fd1e5782
A variable typed as
int|false
is compared with zero ($length > 0
). Afterwards, Psalm correctly infers that it has to be 1 or higher (int<1, max>
). But it still considersfalse
to be possible although(false > 0) === false
.The text was updated successfully, but these errors were encountered: