-
Notifications
You must be signed in to change notification settings - Fork 660
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
Null wrongly added as possible variable value #9395
Labels
Comments
I found these snippets: https://psalm.dev/r/1502d48747<?php
$a = -1;
if ($a !== null) {
}
echo $a;
|
This comment was marked as outdated.
This comment was marked as outdated.
I found these snippets: https://psalm.dev/r/27a443b1bf<?php
function f(): int {
$a = -1;
/** @psalm-suppress RedundantCondition */
if ($a !== null) {}
return $a;
}
|
Is this the same behavior as #9348? |
It certainly looks similar. |
I thought this was a recently introduced issue, but it's not. It was broken since at least 3.4.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Psalm adds null as a possible value to a variable that never gets assigned null.
After the comparison
$a
s value according to psalm is-1|null
Obviously the if block serves no purpose here. However the same problem occurred in a more complex function where an
int
variable was compared to anint|null
variable.https://psalm.dev/r/1502d48747
The text was updated successfully, but these errors were encountered: