Skip to content

Commit 55dd953

Browse files
authored
Merge pull request #12381 from acoglio/patch-4
Improve description of break/continue restrictions.
2 parents 2a587b2 + d17f720 commit 55dd953

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

docs/yul.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,24 @@ evaluate to zero values.
541541

542542
In all other situations, expressions have to evaluate to exactly one value.
543543

544-
The ``continue`` and ``break`` statements can only be used inside loop bodies
545-
and have to be in the same function as the loop (or both have to be at the
546-
top level). The ``continue`` and ``break`` statements cannot be used
547-
in other parts of a loop, not even when it is scoped inside a second loop's body.
544+
A ``continue`` or ``break`` statement can only be used inside the body of a for-loop, as follows.
545+
Consider the innermost loop that contains the statement.
546+
The loop and the statement must be in the same function, or both must be at the top level.
547+
The statement must be in the loop's body block;
548+
it cannot be in the loop's initialization block or update block.
549+
It is worth emphasizing that this restriction applies just
550+
to the innermost loop that contains the ``continue`` or ``break`` statement:
551+
this innermost loop, and therefore the ``continue`` or ``break`` statement,
552+
may appear anywhere in an outer loop, possibly in an outer loop's initialization block or update block.
553+
For example, the following is legal,
554+
because the ``break`` occurs in the body block of the inner loop,
555+
despite also occurring in the update block of the outer loop:
556+
557+
.. code-block:: yul
558+
559+
for {} true { for {} true {} { break } }
560+
{
561+
}
548562
549563
The condition part of the for-loop has to evaluate to exactly one value.
550564

0 commit comments

Comments
 (0)