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

Type inference issue #11242

Open
danog opened this issue Feb 4, 2025 · 1 comment
Open

Type inference issue #11242

danog opened this issue Feb 4, 2025 · 1 comment
Labels

Comments

@danog
Copy link
Collaborator

danog commented Feb 4, 2025

Just for reference, may just be the expression complexity limit: https://psalm.dev/r/d2ebbc2264

@danog danog added the bug label Feb 4, 2025
Copy link

I found these snippets:

https://psalm.dev/r/d2ebbc2264
<?php


function test(PhpParser\Node $node): void
{
    if ($node instanceof PhpParser\Node\Stmt\Namespace_) {
    } elseif ($node instanceof PhpParser\Node\FunctionLike
              || $node instanceof PhpParser\Node\Stmt\Expression
                 && true
              || $node instanceof PhpParser\Node\Arg
                 && true
              || ($node instanceof PhpParser\Node\ArrayItem
                 && true)
     ) {
	   /** @psalm-check-type-exact $node = PhpParser\Node\Arg|PhpParser\Node\ArrayItem|PhpParser\Node\FunctionLike|PhpParser\Node\Stmt\Expression */;
    }
}
Psalm output (using commit 53140ea):

ERROR: RedundantCondition - 9:21 - Operand of type true is always truthy

ERROR: RedundantCondition - 11:21 - Operand of type true is always truthy

ERROR: RedundantCondition - 13:21 - Operand of type true is always truthy

ERROR: CheckType - 15:146 - Checked variable $node = PhpParser\Node\Arg|PhpParser\Node\ArrayItem|PhpParser\Node\FunctionLike|PhpParser\Node\Stmt\Expression does not match $node = PhpParser\Node

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

No branches or pull requests

1 participant