-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Bug report
Code snippet that reproduces the problem
https://phpstan.org/r/a5262532-e32a-4c45-8340-e96e4931cbda
Expected output
No warnings should be emitted because an infinite loop in a generator is completely fine as long as you don't iterate on it indefinitely. It is just the same as the builtin InfiniteIterator.
This warning should still be emitted if there is an infinite loop that does not contain a yield statement, because there's no way the loop can be broken. But a yield in a loop is effectively a break that just continues when the generator is resumed.
In case anyone is wondering, an infinite loop in a generator does not lead to memory leak (unlike golang goroutines that block forever): https://3v4l.org/Da4Q8 we can see that MustGc is destructed after the generator is no longer used.
Reactions are currently unavailable