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
Assertion dependent type not recognized in dev-master, but works in 4.x-dev. #7968
Labels
Comments
I found these snippets: https://psalm.dev/r/8979ac9579<?php
function test(mixed $mixed, bool $b) : void
{
if ($b && !is_string($mixed))
return;
echo $b ? $mixed : '';
}
|
This is a somewhat more simple reproducer: https://psalm.dev/r/3b5374dddc but removing the ternary fixes it: https://psalm.dev/r/7a167ba5cd So it’s likely an issue with ternary analysis. I’ll have a look at this tomorrow if you don’t get to it. |
I found these snippets: https://psalm.dev/r/3b5374dddc<?php
function test(string|object $s, bool $b) : string
{
if (!$b || is_string($s)) {
return $b ? $s : '';
}
return '';
}
https://psalm.dev/r/7a167ba5cd<?php
function test(string|object $s, bool $b) : string
{
if (!$b || is_string($s)) {
if ($b) {
return $s;
} else {
return '';
}
}
return '';
}
|
muglug
added a commit
that referenced
this issue
May 20, 2022
Fixed in latest by ensuring clause simplification in ternaries matches behaviour in if/else analysis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/8979ac9579
The text was updated successfully, but these errors were encountered: