mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Improve description of break/continue restrictions.
This is as discussed on Element, with enhancements discussed with @cameel.
This commit is contained in:
parent
248bc387cd
commit
d17f7206ad
22
docs/yul.rst
22
docs/yul.rst
@ -541,10 +541,24 @@ evaluate to zero values.
|
|||||||
|
|
||||||
In all other situations, expressions have to evaluate to exactly one value.
|
In all other situations, expressions have to evaluate to exactly one value.
|
||||||
|
|
||||||
The ``continue`` and ``break`` statements can only be used inside loop bodies
|
A ``continue`` or ``break`` statement can only be used inside the body of a for-loop, as follows.
|
||||||
and have to be in the same function as the loop (or both have to be at the
|
Consider the innermost loop that contains the statement.
|
||||||
top level). The ``continue`` and ``break`` statements cannot be used
|
The loop and the statement must be in the same function, or both must be at the top level.
|
||||||
in other parts of a loop, not even when it is scoped inside a second loop's body.
|
The statement must be in the loop's body block;
|
||||||
|
it cannot be in the loop's initialization block or update block.
|
||||||
|
It is worth emphasizing that this restriction applies just
|
||||||
|
to the innermost loop that contains the ``continue`` or ``break`` statement:
|
||||||
|
this innermost loop, and therefore the ``continue`` or ``break`` statement,
|
||||||
|
may appear anywhere in an outer loop, possibly in an outer loop's initialization block or update block.
|
||||||
|
For example, the following is legal,
|
||||||
|
because the ``break`` occurs in the body block of the inner loop,
|
||||||
|
despite also occurring in the update block of the outer loop:
|
||||||
|
|
||||||
|
.. code-block:: yul
|
||||||
|
|
||||||
|
for {} true { for {} true {} { break } }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
The condition part of the for-loop has to evaluate to exactly one value.
|
The condition part of the for-loop has to evaluate to exactly one value.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user