You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you multiply -1 and INF, the returned type is -INF. This is okay. If you multiply 1 and INF, the returned type is INF. This is okay. However, if you multiply 0 and INF, the returned type is mixed.
The result of multiplying 0 and INF, as interpreted by php when executing var_dump(0*INF); is float(NAN). I think the phpstan type should be float, or the more specific type NAN.
To highlight the inconsistency, if you multiply an integer and INF, you might think that phpstan would return mixed to be consistent with the above, since 0 is in the set of all integers. However, phpstan thinks this is a float.
Uh oh!
There was an error while loading. Please reload this page.
Bug report
If you multiply
-1
andINF
, the returned type is-INF
. This is okay. If you multiply1
andINF
, the returned type isINF
. This is okay. However, if you multiply0
andINF
, the returned type ismixed
.https://phpstan.org/r/ab49cb02-8fea-4af2-b934-79ada367618f
I think this is a bug.
mixed
is too wide.Code snippet that reproduces the problem
https://phpstan.org/r/ab49cb02-8fea-4af2-b934-79ada367618f
Expected output
The result of multiplying
0
andINF
, as interpreted by php when executingvar_dump(0*INF);
isfloat(NAN)
. I think the phpstan type should befloat
, or the more specific typeNAN
.To highlight the inconsistency, if you multiply an integer and
INF
, you might think that phpstan would returnmixed
to be consistent with the above, since0
is in the set of all integers. However, phpstan thinks this is afloat
.https://phpstan.org/r/b5d371cb-8026-4388-882d-ec709df94308
... but if you limit the integers to a specific set that includes
0
(e.g.-1|0|1
), it does returnmixed
...https://phpstan.org/r/44f43ecd-f086-49fe-9554-5e2915a22223
whereas perhaps it should return
-INF|NAN|INF
orfloat
for this specific example.Did PHPStan help you today? Did it make you happy in any way?
Yes.
The text was updated successfully, but these errors were encountered: