Repository navigation
fix(switch): continue N targeting an outer switch leaves it like break N - #14368
Conversation
…k N vimeo#14018 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 429791e. Configure here.
✅ Performance: unchanged · Types: unchanged
How to read this table
head 3923b3a · base c5f4dfd (merge-base) · workflow run |
…h of the case vimeo#14018 Outer switches are given to the case actions as their own break type, so that `break N` and `continue N` past the switch of the case stay a way out of it, as master's nested `break 2` handling expects, instead of looking like a `break` of that switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orklah
left a comment
There was a problem hiding this comment.
Thanks, the fix is right on every nesting I tried (switch > loop > switch with continue 3, a loop
between the switches, all cases leaving with continue 2).
One thing: continueTargetingAnOuterSwitchInALoopLeavesTheSwitchNotTheLoop also passes on master, since
it asserts no type and master reports nothing there, although master gets that path wrong. Could you make
it assert the type? For example:
'continueTargetingAnOuterSwitchInALoopLeavesTheSwitchNotTheLoop' => [
'code' => '<?php
$r = 0;
foreach (["A", "B"] as $s) {
switch ($s) {
case "A":
switch (uniqid()) {
case "x":
$q = 1;
continue 2;
}
$q = 2;
break;
default:
$q = 3;
}
$r = $q;
}',
'assertions' => [
'$r===' => '1|2|3', // master: 0|2|3
],
'ignored_issues' => [],
'php_version' => '7.4',
],…f the variable It passed on master as well because it asserted nothing; $r is 1|2|3 here and 0|2|3 on master. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

continue Nwhose target is an outerswitchis reported asContinueOutsideLoop, and the variables it carries out of the switch are lost.Before
After
// $q: 1|2|3, in PHP `continue 2` targeting a switch acts like `break 2`Fixes #14018