-
-
Notifications
You must be signed in to change notification settings - Fork 942
Description
Bug report
In Scssphp, I got good results in my parsing code regarding the tracking of which function will return the same thing again on next call, by tagging functions of the scanner that moves the position with @phpstan-impure.
I only got one issue when a while condition involves 2 conditions, with the second one calling that impure function. phpstan reports that the first part of the condition is always true. However, this is not actually true. The first part of the condition is indeed always true for the first iteration, but the second half of the condition being impure means that the state won't be the same anymore on the next iteration.
To me, it looks like the analyser does not properly account for the fact that 2 code paths are reaching that method calls, with only one of them being always true.
Code snippet that reproduces the problem
https://phpstan.org/r/2710cc55-0133-4530-a861-cef0804670db
Expected output
no issue should be reported
Did PHPStan help you today? Did it make you happy in any way?
This tracking of the state of the scanner based on impure vs pure functions is really impressive. It was able to find some dead code in another part of the parser, which even allowed me to remove the corresponding dead code in the reference Sass parser in dart-sass.