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

@psalm-return true not checked, while @psalm-return false is checked #2914

Closed
Ocramius opened this issue Mar 5, 2020 · 1 comment
Closed
Labels

Comments

@Ocramius
Copy link
Contributor

Ocramius commented Mar 5, 2020

In https://psalm.dev/r/58faa57709, psalm detects a mismatch between @psalm-return false and return true.

In https://psalm.dev/r/ddb1fce230, psalm detects a mismatch between @psalm-return true and return false.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/58faa57709
<?php
  
/** @psalm-return false */
function alwaysFalse() : bool
{
    return true;
}
Psalm output (using commit 8a1067e):

ERROR: InvalidReturnStatement - 6:12 - The inferred type 'true' does not match the declared return type 'false' for alwaysFalse

ERROR: InvalidReturnType - 3:19 - The declared return type 'false' for alwaysFalse is incorrect, got 'true'
https://psalm.dev/r/ddb1fce230
<?php
  
/** @psalm-return true */
function alwaysTrue() : bool
{
    return false;
}
Psalm output (using commit 8a1067e):

No issues!

@muglug muglug added the bug label Mar 5, 2020
leightonthomas added a commit to leightonthomas/psalm that referenced this issue Mar 9, 2020
@muglug muglug closed this as completed in 60fb392 Mar 9, 2020
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

2 participants