-
Notifications
You must be signed in to change notification settings - Fork 680
Boolean match in strict binary operands mode emits an error #8562
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
Comments
I found these snippets: https://psalm.dev/r/e58299f88a<?php
class a {}
class b {}
function a(object $item): string {
return match (true) {
$item instanceof a => 'a',
$item instanceof b => 'b',
};
}
|
Do you have this error on another version of Psalm? The snippet seems fine as is |
This error is happening on upstream master, but the |
Ok :) The fix should just be to check whether $conditional is a VirtualNotIdentical here:
And there is another with VirtualIdentical in the same file |
Hmm, isn't it a bit hacky? |
Well, I introduced Virtual nodes exactly for this kind of reason (I was creating a plugin and I needed to differentiate between real code nodes and Virtual nodes created by Psalm for easier analysis. See #5215). So here, Psalm is creating a virtual node with === instead of a match expression so just by checking that, you can deduce it's not really a code that's in the file so it shouldn't be considered as unnecessary |
https://psalm.dev/r/e58299f88a
The text was updated successfully, but these errors were encountered: