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

Error at wrong place for redundant condition with ternary expression #11118

Open
M393 opened this issue Oct 10, 2024 · 1 comment
Open

Error at wrong place for redundant condition with ternary expression #11118

M393 opened this issue Oct 10, 2024 · 1 comment

Comments

@M393
Copy link

M393 commented Oct 10, 2024

https://psalm.dev/r/7832c75a2a

Why is the error position at the else part of the ternary?

ERROR: RedundantCondition - 4:23 - Type list{'a'} for $a is always non-empty-countable

This error does not exist when an if-else is used instead of a ternary.

Copy link

I found these snippets:

https://psalm.dev/r/7832c75a2a
<?php

$a = ['a'];
$_b = $a === [] ? 0 : 1;

if ($a === []) {
    $_c = 0;
} else {
    $_c = 1;
}
Psalm output (using commit dee5fe4):

ERROR: TypeDoesNotContainType - 4:7 - list{string} does not contain empty array

ERROR: TypeDoesNotContainType - 4:7 - Type list{'a'} for $a is always !non-empty-countable

ERROR: RedundantCondition - 4:23 - Type list{'a'} for $a is always non-empty-countable

ERROR: TypeDoesNotContainType - 6:5 - list{string} does not contain empty array

ERROR: TypeDoesNotContainType - 6:5 - Type list{'a'} for $a is always !non-empty-countable

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

No branches or pull requests

1 participant