143 - solc 0.8.0 Restrictions
Solidity v0.8.0 New Restrictions - changes that might cause existing contracts to not compile anymore:
-
Explicit conversions from negative literals and literals larger than
type(uint160).max
to address are disallowed. -
Explicit conversions between literals and an integer type
T
are only allowed if the literal lies betweentype(T).min
andtype(T).max
. In particular, replace usages ofuint(-1)
withtype(uint).max
. -
Explicit conversions between literals and enums are only allowed if the literal can represent a value in the enum.
-
Explicit conversions between literals and address type (e.g.
address(literal)
) have the type address instead of address payable. One can get a payable address type by using an explicit conversion, i.e., payable(literal). -
Address literals have the type
address
instead ofaddress payable
. They can be converted to address payable by using an explicit conversion -
Function call options can only be given once, i.e.
c.f{gas: 10000}{value: 1}()
is invalid and has to be changed toc.f{gas: 10000, value: 1}()
-
The global functions
log0
,log1
,log2
,log3
and log4 have been removed. These are low-level functions that were largely unused. Their behaviour can be accessed from inline assembly. -
enum definitions cannot contain more than 256 members. This will make it safe to assume that the underlying type in the ABI is always uint8.
-
Declarations with the name
this
,super
and_
are disallowed, with the exception of public functions and events. -
The global variables
tx.origin
andmsg.sender
have the type address instead of address payable. One can convert them into address payable by using an explicit conversion. -
Explicit conversion into address type always returns a non-payable
address
type -
The
chainid
builtin in inline assembly is now consideredview
instead ofpure
- Explicit Conversions
- Addr Literals -> address
- Fn Call Options -> Once
log0
-log4
-> Removedenum
-> 256/uint8
- X ->
this
,super
,_
tx.origin
/msg.sender
chainID
->view