mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
docs: Clarify how modifiers can affect function arguments and return values
This commit is contained in:
parent
67dea6c4f1
commit
e1464fa4fb
@ -108,13 +108,24 @@ limited to functions of the same library.
|
|||||||
Multiple modifiers are applied to a function by specifying them in a
|
Multiple modifiers are applied to a function by specifying them in a
|
||||||
whitespace-separated list and are evaluated in the order presented.
|
whitespace-separated list and are evaluated in the order presented.
|
||||||
|
|
||||||
|
Modifiers cannot implicitly access or change the arguments and return values of functions they modify.
|
||||||
|
Their values can only be passed to them explicitly at the point of invocation.
|
||||||
|
|
||||||
|
Explicit returns from a modifier or function body only leave the current
|
||||||
|
modifier or function body. Return variables are assigned and
|
||||||
|
control flow continues after the ``_`` in the preceding modifier.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
In an earlier version of Solidity, ``return`` statements in functions
|
In an earlier version of Solidity, ``return`` statements in functions
|
||||||
having modifiers behaved differently.
|
having modifiers behaved differently.
|
||||||
|
|
||||||
Explicit returns from a modifier or function body only leave the current
|
An explicit return from a modifier with ``return;`` does not affect the values returned by the function.
|
||||||
modifier or function body. Return variables are assigned and
|
The modifier can, however, choose not to execute the function body at all and in that case the return
|
||||||
control flow continues after the "_" in the preceding modifier.
|
variables are set to their :ref:`default values<default-value>` just as if the function had an empty
|
||||||
|
body.
|
||||||
|
|
||||||
|
The ``_`` symbol can appear in the modifier multiple times. Each occurrence is replaced with
|
||||||
|
the function body.
|
||||||
|
|
||||||
Arbitrary expressions are allowed for modifier arguments and in this context,
|
Arbitrary expressions are allowed for modifier arguments and in this context,
|
||||||
all symbols visible from the function are visible in the modifier. Symbols
|
all symbols visible from the function are visible in the modifier. Symbols
|
||||||
|
Loading…
Reference in New Issue
Block a user