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
{{ message }}
Repository navigation
Commit 2f59b3c
Browse filesBrowse the repository at this point in the historyBrowse files
Forget only the still-changing variables when a loop reaches the iteration limit
A loop that did not converge within LOOP_SCOPE_ITERATIONS passes turned
every variable it writes into mixed. A single variable whose type never
equals itself between passes - phpstan-doctrine's query builder types
are keyed by uniqid() - so took every other variable of the loop with it:
for ($i = 0; $i < 12; $i++) { $qb = $factory->where('a'); $to = $to->minusMonths(1); }
// $to was mixed, $i NAN|float|int
At the limit each further pass now calls
MutatingScope::forgetChangedLoopVariables(), which makes only the
variables whose type changed since the previous head mixed and lets the
loop iterate on. A forgotten variable that is reassigned changes again and
is forgotten again, so the head stops changing once every non-converging
variable is mixed. When what still changes is not a variable, or the loop
has not converged after LOOP_SCOPE_FORGETTING_ITERATIONS_LIMIT more
passes, it forgets everything the loop writes as before. The native loop
handlers and MutatingScope follow the same logic.
Amp-Thread-ID: https://ampcode.com/threads/T-01a21efd-56f1-73e5-84f4-12131a86dbe9
0 commit comments