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

Spurious errors resulting from psalm asserting a boolean is always false #3685

Closed
mstilkerich opened this issue Jun 26, 2020 · 1 comment
Closed
Labels
bug hard problems Problems without an obvious easy solution

Comments

@mstilkerich
Copy link
Contributor

Hello,

I have a couple of spurious errors reported by psalm related to a boolean that psalm seems to assume being always false. I reduced the code to the following which still reproduces the error messages: https://psalm.dev/r/acfa45bb65

In the real code, the function is called with both true and false values for the parameter. I can add calls with true / false parameter to the sample snippet and the errors will also still be reported. This looks like a bug to me, but if it's a misunderstanding on my end I would also appreciate info to understand the cause for these errors to be able to fix them.

@psalm-github-bot
Copy link

I found these snippets:

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

function testFunc(bool $pst): void
{
        do {
                $status = rand();
                if (($pst === false) && ($status == 412)) {
                }
        } while (($pst === false) && ($status == 412));

        if ($pst === true) {
        }
}
Psalm output (using commit bcd7478):

ERROR: RedundantCondition - 7:21 - Found a redundant condition when evaluating $pst and trying to reconcile type 'false' to false

ERROR: TypeDoesNotContainType - 11:13 - false does not contain true

@weirdan weirdan added the bug label Jun 26, 2020
@muglug muglug added the hard problems Problems without an obvious easy solution label Jun 26, 2020
@muglug muglug closed this as completed in 0c582e9 Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug hard problems Problems without an obvious easy solution
Projects
None yet
Development

No branches or pull requests

3 participants