mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
commit
a46c685295
@ -12,45 +12,45 @@ For the full list check
|
|||||||
Silent Changes of the Semantics
|
Silent Changes of the Semantics
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
* Exponentiation and shifts of literals by non-literals (e.g. ``1 << x`` or ``2 ** x``)
|
* Exponentiation and shifts of literals by non-literals (e.g. ``1 << x`` or ``2 ** x``)
|
||||||
will always use either the type ``uint256`` (for non-negative literals) or
|
will always use either the type ``uint256`` (for non-negative literals) or
|
||||||
``int256`` (for negative literals) to perform the operation.
|
``int256`` (for negative literals) to perform the operation.
|
||||||
Previously, the operation was performed in the type of the shift amount / the
|
Previously, the operation was performed in the type of the shift amount / the
|
||||||
exponent which can be misleading.
|
exponent which can be misleading.
|
||||||
|
|
||||||
|
|
||||||
Changes to the Syntax
|
Changes to the Syntax
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
* In external function and contract creation calls, Ether and gas is now specified using a new syntax:
|
* In external function and contract creation calls, Ether and gas is now specified using a new syntax:
|
||||||
``x.f{gas: 10000, value: 2 ether}(arg1, arg2)``.
|
``x.f{gas: 10000, value: 2 ether}(arg1, arg2)``.
|
||||||
The old syntax -- ``x.f.gas(10000).value(2 ether)(arg1, arg2)`` -- will cause an error.
|
The old syntax -- ``x.f.gas(10000).value(2 ether)(arg1, arg2)`` -- will cause an error.
|
||||||
* The global variable ``now`` is deprecated, ``block.timestamp`` should be used instead.
|
* The global variable ``now`` is deprecated, ``block.timestamp`` should be used instead.
|
||||||
The single identifier ``now`` is too generic for a global variable and could give the impression
|
The single identifier ``now`` is too generic for a global variable and could give the impression
|
||||||
that it changes during transaction processing, whereas ``block.timestamp`` correctly
|
that it changes during transaction processing, whereas ``block.timestamp`` correctly
|
||||||
reflects the fact that it is just a property of the block.
|
reflects the fact that it is just a property of the block.
|
||||||
* NatSpec comments on variables are only allowed for public state variables and not
|
* NatSpec comments on variables are only allowed for public state variables and not
|
||||||
for local or internal variables.
|
for local or internal variables.
|
||||||
|
|
||||||
* The token ``gwei`` is a keyword now (used to specify, e.g. ``2 gwei`` as a number)
|
* The token ``gwei`` is a keyword now (used to specify, e.g. ``2 gwei`` as a number)
|
||||||
and cannot be used as an identifier.
|
and cannot be used as an identifier.
|
||||||
|
|
||||||
* State Mutability: The state mutability of functions can now be restricted during inheritance:
|
* State Mutability: The state mutability of functions can now be restricted during inheritance:
|
||||||
Functions with default state mutability can be overridden by ``pure`` and ``view`` functions
|
Functions with default state mutability can be overridden by ``pure`` and ``view`` functions
|
||||||
while ``view`` functions can be overridden by ``pure`` functions.
|
while ``view`` functions can be overridden by ``pure`` functions.
|
||||||
At the same time, public state variables are considered ``view`` and even ``pure``
|
At the same time, public state variables are considered ``view`` and even ``pure``
|
||||||
if they are constants.
|
if they are constants.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Inline Assembly
|
Inline Assembly
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
* Disallow ``.`` in user-defined function and variable names in inline assembly.
|
* Disallow ``.`` in user-defined function and variable names in inline assembly.
|
||||||
It is still valid if you use Solidity in Yul-only mode.
|
It is still valid if you use Solidity in Yul-only mode.
|
||||||
|
|
||||||
* Slot and offset of storage pointer variable ``x`` are accessed via ``x.slot``
|
* Slot and offset of storage pointer variable ``x`` are accessed via ``x.slot``
|
||||||
and ``x.offset`` instead of ``x_slot`` and ``x_offset``.
|
and ``x.offset`` instead of ``x_slot`` and ``x_offset``.
|
||||||
|
|
||||||
Removal of Unused or Unsafe Features
|
Removal of Unused or Unsafe Features
|
||||||
====================================
|
====================================
|
||||||
@ -58,54 +58,54 @@ Removal of Unused or Unsafe Features
|
|||||||
Mappings outside Storage
|
Mappings outside Storage
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
* If a struct or array contains a mapping, it can only be used in storage.
|
* If a struct or array contains a mapping, it can only be used in storage.
|
||||||
Previously, mapping members were silently skipped in memory, which
|
Previously, mapping members were silently skipped in memory, which
|
||||||
is confusing and error-prone.
|
is confusing and error-prone.
|
||||||
|
|
||||||
* Assignments to structs or arrays in storage does not work if they contain
|
* Assignments to structs or arrays in storage does not work if they contain
|
||||||
mappings.
|
mappings.
|
||||||
Previously, mappings were silently skipped during the copy operation, which
|
Previously, mappings were silently skipped during the copy operation, which
|
||||||
is misleading and error-prone.
|
is misleading and error-prone.
|
||||||
|
|
||||||
Functions and Events
|
Functions and Events
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
* Visibility (``public`` / ``external``) is not needed for constructors anymore:
|
* Visibility (``public`` / ``external``) is not needed for constructors anymore:
|
||||||
To prevent a contract from being created, it can be marked ``abstract``.
|
To prevent a contract from being created, it can be marked ``abstract``.
|
||||||
This makes the visibility concept for constructors obsolete.
|
This makes the visibility concept for constructors obsolete.
|
||||||
|
|
||||||
* Type Checker: Disallow ``virtual`` for library functions:
|
* Type Checker: Disallow ``virtual`` for library functions:
|
||||||
Since libraries cannot be inherited from, library functions should not be virtual.
|
Since libraries cannot be inherited from, library functions should not be virtual.
|
||||||
|
|
||||||
* Multiple events with the same name and parameter types in the same
|
* Multiple events with the same name and parameter types in the same
|
||||||
inheritance hierarchy are disallowed.
|
inheritance hierarchy are disallowed.
|
||||||
|
|
||||||
* ``using A for B`` only affects the contract it is mentioned in.
|
* ``using A for B`` only affects the contract it is mentioned in.
|
||||||
Previously, the effect was inherited. Now, you have to repeat the ``using``
|
Previously, the effect was inherited. Now, you have to repeat the ``using``
|
||||||
statement in all derived contracts that make use of the feature.
|
statement in all derived contracts that make use of the feature.
|
||||||
|
|
||||||
Expressions
|
Expressions
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
* Shifts by signed types are disallowed.
|
* Shifts by signed types are disallowed.
|
||||||
Previously, shifts by negative amounts were allowed, but reverted at runtime.
|
Previously, shifts by negative amounts were allowed, but reverted at runtime.
|
||||||
|
|
||||||
* The ``finney`` and ``szabo`` denominations are removed.
|
* The ``finney`` and ``szabo`` denominations are removed.
|
||||||
They are rarely used and do not make the actual amount readily visible. Instead, explicit
|
They are rarely used and do not make the actual amount readily visible. Instead, explicit
|
||||||
values like ``1e20`` or the very common ``gwei`` can be used.
|
values like ``1e20`` or the very common ``gwei`` can be used.
|
||||||
|
|
||||||
Declarations
|
Declarations
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* The keyword ``var`` cannot be used anymore.
|
* The keyword ``var`` cannot be used anymore.
|
||||||
Previously, this keyword would parse but result in a type error and
|
Previously, this keyword would parse but result in a type error and
|
||||||
a suggestion about which type to use. Now, it results in a parser error.
|
a suggestion about which type to use. Now, it results in a parser error.
|
||||||
|
|
||||||
Interface Changes
|
Interface Changes
|
||||||
=================
|
=================
|
||||||
|
|
||||||
* JSON AST: Members with value ``null`` are removed from JSON output.
|
* JSON AST: Members with value ``null`` are removed from JSON output.
|
||||||
* NatSpec: Constructors and functions have consistent userdoc output.
|
* NatSpec: Constructors and functions have consistent userdoc output.
|
||||||
|
|
||||||
|
|
||||||
How to update your code
|
How to update your code
|
||||||
|
Loading…
Reference in New Issue
Block a user