Open TysonAndre opened 5 years ago
basically it's useful when comparing two unions A and B that don't both have the same scalar type, where A and/or B has an always truthy or always falsy value
e.g.
string
compared to null
,
string|false
compared to non-empty-array
,
int|false
compared to array<empty, empty>
Marking as a bug because Psalm really should have caught the first line as it did the next: https://psalm.dev/r/e7ff542f98 (also maybe related to #1684)
Some examples of code it might be useful for psalm to warn about are below. Currently, psalm does not warn, because the code uses
==
instead of===
.E.g. could add a
QuestionableLooseEqualityCheck comparing int to string(false)'
issue type for the checks involving strings/numbers/null on either side