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 2a70999
Browse filesBrowse the repository at this point in the historyBrowse files
Walk a while loop's exit condition instead of narrowing the body's scope by it
After the body ran, the loop exits through the condition evaluated again.
The post-loop scope was the body's back-edge scope narrowed by the
condition's falsey types, without the condition itself running there, so
an assignment in it narrowed the body's stale value instead of replacing
it: in `while ($row = fetchRow())` the body's array{mixed} $row became
never. Matching conditional expressions on a never guard then fixed
variables set under a condition on $row to their our-branch type, such as
$printed to true. The condition is now walked on the back-edge scope and
the loop exits through its falsey scope, which also counts side effects
such as `$i++` in the condition.
When the loop may not run at all, the post-loop scope merges the exit
scope with the scope where the first condition was falsey. These are
alternative paths like an if's branches, so the merge now keeps a
conditional expression that only one path records when the other path
makes it vacuously true, as IfHandler does. Without it, the correlation
`$rows !== 0` implies `$stop` after
`while (!($stop = $s->stop()) && ($rows = $s->next()))` was lost when
polluteScopeWithLoopInitialAssignments is off (as in strict-rules).
Amp-Thread-ID: https://ampcode.com/threads/T-01a1d722-328d-734b-b55e-1eb10133f833
0 commit comments