diff --git a/docs/080-breaking-changes.rst b/docs/080-breaking-changes.rst index 05deab9c4..d211b3aac 100644 --- a/docs/080-breaking-changes.rst +++ b/docs/080-breaking-changes.rst @@ -129,13 +129,13 @@ This section lists changes that might cause existing contracts to not compile an particular, the following explicit conversions have the type ``address`` instead of ``address payable``: - - ``address(u)`` where ``u`` is an arbitrary variable of type ``uint160``. One can convert ``u`` + - ``address(u)`` where ``u`` is a variable of type ``uint160``. One can convert ``u`` into the type ``address payable`` by using two explicit conversions, i.e., ``payable(address(u))``. - - ``address(b)`` where ``b`` is an arbitrary variable of type ``bytes20``. One can convert ``b`` + - ``address(b)`` where ``b`` is a variable of type ``bytes20``. One can convert ``b`` into the type ``address payable`` by using two explicit conversions, i.e., ``payable(address(b))``. - - ``address(c)`` where ``c`` is an arbitrary contract. Previously, the return type of this + - ``address(c)`` where ``c`` is a contract. Previously, the return type of this conversion depended on whether the contract can receive Ether (either by having a receive function or a payable fallback function). The conversion ``payable(c)`` has the type ``address payable`` and is only allowed when the contract ``c`` can receive Ether. In general, one can diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index 3f74a7f5d..5e88058c3 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -188,17 +188,14 @@ Type conversions: Implicit conversions from ``address payable`` to ``address`` are allowed, whereas conversions from ``address`` to ``address payable`` must be explicit via ``payable(
)``. -Explicit conversions to and from ``address`` are allowed for integers, integer literals, ``bytes20`` and contract types with the following -caveat: -The result of a conversion of the form ``address(x)`` -has the type ``address payable``, if ``x`` is of integer or fixed bytes type, -or a contract with a receive or payable fallback function. -If ``x`` is a contract without a receive or payable fallback function, -then ``address(x)`` will be of type ``address``. -Similarly, if ``x`` is a literal, then ``address(x)`` will also be of type ``address``. -In external function signatures ``address`` is used for both the ``address`` and the ``address payable`` type. +Explicit conversions to and from ``address`` are allowed for ``uint160``, integer literals, +``bytes20`` and contract types. -Only expressions of type ``address`` can be converted to type ``address payable`` via ``payable(
)``. +Only expressions of type ``address`` and contract-type can be converted to the type ``address +payable`` via the explicit conversion ``payable(...)``. For contract-type, this conversion is only +allowed if the contract can receive Ether, i.e., the contract either has a :ref:`receive +` or a payable fallback function. Note that ``payable(0)`` is valid and is +an exception to this rule. .. note:: If you need a variable of type ``address`` and plan to send Ether to it, then