From 6076cc93fbb655c74880c94d30e4eb1f2d4b6a99 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 12 Dec 2019 18:02:16 +0100 Subject: [PATCH 1/4] Update changes for 0.6.0 --- docs/060-breaking-changes.rst | 115 +++++++++++++++++----------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/docs/060-breaking-changes.rst b/docs/060-breaking-changes.rst index 1d327b824..177d91d20 100644 --- a/docs/060-breaking-changes.rst +++ b/docs/060-breaking-changes.rst @@ -9,29 +9,43 @@ For the full list check `the release changelog `_. -Syntactic Only Changes -====================== +Changes the Compiler Might not Warn About +========================================= -This section lists purely syntactic changes that do not affect the behavior of existing code. +This section lists changes where the behaviour of your code might +change without the compiler telling you about it. -* Conversions from external function types to ``address`` are now disallowed. Instead external - function types have a member called ``address``, similar to the existing ``selector`` member. -* Conversions from ``address`` to ``address payable`` are now possible via ``payable(x)``, where - ``x`` must be of type ``address``. +* The resulting type of an exponentiation is the type of the base. It used to be the smallest type + that can hold both the type of the base and the type of the exponent, as with symmentric + operations. Additionally, signed types are allowed for the base of the exponetation. -* Function ``push(value)`` for dynamic storage arrays do not return the new length anymore. + +Explicitness Requirements +========================= + +This section lists changes where the code now needs to be more explicit, +but the semantics to do not change. +For most of the topics the compiler will provide suggestions. + +* Functions can now only be overridden when they are either marked with the + ``virtual`` keyword or defined in an interface. Functions without + implementation outside an interface have to be marked ``virtual``. + When overriding a function or modifier, the new keyword ``override`` + must be used. When overriding a function or modifier defined in multiple + parallel bases, all bases must be listed in parentheses after the keyword + like so: ``override(Base1, Base2)``. + +* Member-access to ``length`` of arrays is now always read-only, even for storage arrays. It is no + longer possible to resize storage arrays assigning a new value to their length. Use ``push()``, + ``push(value)`` or ``pop()`` instead, or assign a full array, which will of course overwrite existing content. + The reason behind this is to prevent storage collisions by gigantic + storage arrays. * The new keyword ``abstract`` can be used to mark contracts as abstract. It has to be used if a contract does not implement all its functions. * Libraries have to implement all their functions, not only the internal ones. -* Member-access to ``length`` of arrays is now always read-only, even for storage arrays. It's no - longer possible to resize storage arrays assigning a new value to their length. Use ``push()``, - ``push(value)`` or ``pop()`` instead, or assign a full array, which will of course overwrite existing content. - -* New reserved keywords: ``override``, ``receive``, and ``virtual``. - * The names of variables declared in inline assembly may no longer end in ``_slot`` or ``_offset``. * Variable declarations in inline assembly may no longer shadow any declaration outside the inline assembly block. @@ -43,21 +57,16 @@ This section lists purely syntactic changes that do not affect the behavior of e the same name in any of its bases. -Semantic Only Changes -===================== - -This section lists the changes that are semantic-only, thus potentially -hiding new and different behavior in existing code. - - Semantic and Syntactic Changes ============================== -This section highlights changes that affect syntax and semantics. +This section lists changes where you have to modify your code +and it does something else afterwards. -* The resulting type of an exponentiation is the type of the base. It used to be the smallest type - that can hold both the type of the base and the type of the exponent, as with symmentric - operations. Additionally, signed types are allowed for the base of the exponetation. +* Conversions from external function types to ``address`` are now disallowed. Instead external + function types have a member called ``address``, similar to the existing ``selector`` member. + +* The function ``push(value)`` for dynamic storage arrays does not return the new length anymore (it returns nothing). * The unnamed function commonly referred to as "fallback function" was split up into a new fallback function that is defined using the ``fallback`` keyword and a receive ether function @@ -72,13 +81,21 @@ This section highlights changes that affect syntax and semantics. not matching any other function which send value will revert. You should only need to implement the new fallback function if you are following an upgrade or proxy pattern. -* Functions can now only be overridden when they are either marked with the - ``virtual`` keyword or defined in an interface. Functions without - implementation outside an interface have to be marked ``virtual``. - When overriding a function or modifier, the new keyword ``override`` - must be used. When overriding a function or modifier defined in multiple - parallel bases, all bases must be listed in parentheses after the keyword - like so: ``override(Base1, Base2)``. + +New Features +============ + +This section lists things that were not possible prior to Solidity 0.6.0 +or at least more difficult. + + * The :ref:`try/catch statement ` allows you to react on failed external calls. + * ``struct`` and ``enum`` types can be declared at file level. + * Array slices can be used for calldata arrays, for example ``abi.decode(msg.data[4:], (uint, uint))`` + is a low-level way to decode the function call payload. + * Natspec supports multiple return parameters in dev documentation, enforcing the same naming check as ``@param``. + * Yul and Inline Assembly have a new statement called ``leave`` that exits the current function. + * Conversions from ``address`` to ``address payable`` are now possible via ``payable(x)``, where + ``x`` must be of type ``address``. How to update your code @@ -88,7 +105,9 @@ This section gives detailed instructions on how to update prior code for every b * Change ``address(f)`` to ``f.address`` for ``f`` being of external function type. -* Replace ``function () external [payable] { ... }`` by either ``receive() external payable { ... }``, ``fallback() external [payable] { ... }`` or both. Prefer using a ``receive`` function only, whenever possible. +* Replace ``function () external [payable] { ... }`` by either ``receive() external payable { ... }``, + ``fallback() external [payable] { ... }`` or both. Prefer + using a ``receive`` function only, whenever possible. * Change ``uint length = array.push(value)`` to ``array.push(value);``. The new length can be accessed via ``array.length``. @@ -102,27 +121,11 @@ This section gives detailed instructions on how to update prior code for every b parameters like so: ``@return value The return value.``. You can mix named and un-named return parameters documentation so long as the notices are in the order they appear in the tuple return type. -* Choose unique identifiers for variable declarations in inline assembly that do not conflict with declartions outside the inline assembly block. - -* Add ``virtual`` to every non-interface function you intend to override. Add ``virtual`` to all functions without implementation outside interfaces. For single inheritance, add ``override`` to every overriding function. For multiple inheritance, add ``override(A, B, ..)``, where you list all contracts that define the overridden function in the brackets. When multiple bases define the same function, the inheriting contract must override all conflicting functions. - - -New Features -============ - - * The :ref:`try/catch statement ` allows you to react on failed external calls. - * Natspec supports multiple return parameters in dev documentation, enforcing the same naming check as ``@param``. - * Yul and Inline Assembly have a new statement called ``leave`` that exits the current function. - - -Deprecated Elements -=================== - -This section lists changes that deprecate prior features or syntax. - - -.. _interoperability_060: - -Interoperability With Older Contracts -===================================== +* Choose unique identifiers for variable declarations in inline assembly that do not conflict + with declartions outside the inline assembly block. +* Add ``virtual`` to every non-interface function you intend to override. Add ``virtual`` + to all functions without implementation outside interfaces. For single inheritance, add + ``override`` to every overriding function. For multiple inheritance, add ``override(A, B, ..)``, + where you list all contracts that define the overridden function in the parentheses. When + multiple bases define the same function, the inheriting contract must override all conflicting functions. From 9da57ee79135671f40da50386c91117cca16c45e Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 12 Dec 2019 20:05:17 +0100 Subject: [PATCH 2/4] Update docs/060-breaking-changes.rst Co-Authored-By: Bhargava Shastry --- docs/060-breaking-changes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/060-breaking-changes.rst b/docs/060-breaking-changes.rst index 177d91d20..3ab14a2a0 100644 --- a/docs/060-breaking-changes.rst +++ b/docs/060-breaking-changes.rst @@ -24,7 +24,7 @@ Explicitness Requirements ========================= This section lists changes where the code now needs to be more explicit, -but the semantics to do not change. +but the semantics do not change. For most of the topics the compiler will provide suggestions. * Functions can now only be overridden when they are either marked with the From 3438a8d4981409c7739b9addf35d5aa0fac36c23 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 12 Dec 2019 20:05:37 +0100 Subject: [PATCH 3/4] Update docs/060-breaking-changes.rst Co-Authored-By: Bhargava Shastry --- docs/060-breaking-changes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/060-breaking-changes.rst b/docs/060-breaking-changes.rst index 3ab14a2a0..8c70514cf 100644 --- a/docs/060-breaking-changes.rst +++ b/docs/060-breaking-changes.rst @@ -86,7 +86,7 @@ New Features ============ This section lists things that were not possible prior to Solidity 0.6.0 -or at least more difficult. +or at least were more difficult to achieve prior to Solidity 0.6.0. * The :ref:`try/catch statement ` allows you to react on failed external calls. * ``struct`` and ``enum`` types can be declared at file level. From ff3de6cb5d930f178abb6906394d9598a6ad67df Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 12 Dec 2019 20:05:51 +0100 Subject: [PATCH 4/4] Update docs/060-breaking-changes.rst Co-Authored-By: Bhargava Shastry --- docs/060-breaking-changes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/060-breaking-changes.rst b/docs/060-breaking-changes.rst index 8c70514cf..34f1c38e1 100644 --- a/docs/060-breaking-changes.rst +++ b/docs/060-breaking-changes.rst @@ -92,7 +92,7 @@ or at least were more difficult to achieve prior to Solidity 0.6.0. * ``struct`` and ``enum`` types can be declared at file level. * Array slices can be used for calldata arrays, for example ``abi.decode(msg.data[4:], (uint, uint))`` is a low-level way to decode the function call payload. - * Natspec supports multiple return parameters in dev documentation, enforcing the same naming check as ``@param``. + * Natspec supports multiple return parameters in developer documentation, enforcing the same naming check as ``@param``. * Yul and Inline Assembly have a new statement called ``leave`` that exits the current function. * Conversions from ``address`` to ``address payable`` are now possible via ``payable(x)``, where ``x`` must be of type ``address``.