Skip to content

Commit b5ca441

Browse files
committed
Continue on switch emits warning
1 parent ea03278 commit b5ca441

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: spec/11-statements.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,11 @@ number `1` and containing statements having levels increasing by 1.
860860
A `continue` statement terminates the execution of one or more enclosing
861861
[iteration](#iteration-statements) or [`switch`](#the-switch-statement) statements,
862862
up to the specified level. If the statement at the *breakout-level* is an iteration statement,
863-
the next iteration (if any) of the next innermost enclosing iteration or switch statement is started.
863+
the next iteration (if any) of the iteration statement is started.
864864
If that statement is a `for` statement and it has a *for-end-of-loop*, its
865-
end-of-loop expression group for the current iteration is evaluated first. If
865+
end-of-loop expression group for the current iteration is evaluated first. If it
866+
is a `switch` statement, a warning is emitted and the behavior is the same as a
867+
[`break` statement](#the-break-statement) at the same *breakout-level*. If
866868
*breakout-level* is omitted, a level of 1 is assumed.
867869

868870
A `continue` statement may break out of a construct that is fully

Diff for: tests/statements/jump/continue.phpt

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ for ($i = 10; $i <= 40; $i +=10)
8585
echo "\nJust beyond the switch";
8686
}
8787
echo "\n----------\n";
88-
--EXPECT--
88+
--EXPECTF--
89+
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in %s on line %d
8990
1 is odd
9091
3 is odd
9192
5 is odd

0 commit comments

Comments
 (0)