Skip to content

wake.ir.yul.leave module #

YulLeave class #

Bases: YulStatementAbc

Leave statement exits the execution of the current function. It is analogous to the return statement in Solidity, except that it does not accept any arguments to be returned as a return value. Instead, it returns the last-assigned values to the return variables of the function (or default values if none were assigned).

Example

assembly {
    function foo() {
        leave
        // execution stops here
    }
    foo()
    // execution continue here
}
Source code in wake/ir/yul/leave.py
class YulLeave(YulStatementAbc):
    """
    Leave statement exits the execution of the current function.
    It is analogous to the `return` statement in Solidity, except that it does not accept any arguments to be returned as a return value.
    Instead, it returns the last-assigned values to the return variables of the function (or default values if none were assigned).

    !!! example
        ```solidity
        assembly {
            function foo() {
                leave
                // execution stops here
            }
            foo()
            // execution continue here
        }
        ```
    """

    _parent: weakref.ReferenceType[YulBlock]

    @property
    def parent(self) -> YulBlock:
        """
        Returns:
            Parent IR node.
        """
        return super().parent

    @property
    def modifies_state(
        self,
    ) -> Set[Tuple[Union[ExpressionAbc, StatementAbc, YulAbc], ModifiesStateFlag]]:
        return set()

parent: YulBlock property #

Returns:

Type Description
YulBlock

Parent IR node.