Solidity 0.5.0 introduced a number of new features to the language. For a full list of changes, see the changelog here. Some of the changes include:
Semantic Only Changes
Signed right shift now uses proper arithmetic shift, i.e. rounding towards negative infinity, instead of rounding towards zero. Signed and unsigned shift will have dedicated opcodes in Constantinople, and are emulated by Solidity for the moment.
continuestatement in a
do...whileloop now jumps to the condition, which is the common behavior in such cases. It used to jump to the loop body. Thus, if the condition is false, the loop terminates.
.staticcall()do not pad anymore when given a single
Pure and view functions are now called using the opcode
CALLif the EVM version is Byzantium or later. This disallows state changes on the EVM level.
The ABI encoder now properly pads byte arrays and strings from calldata (
msg.dataand external function parameters) when used in external function calls and in
abi.encode. For unpadded encoding, use
The ABI decoder reverts in the beginning of functions and in
abi.decode()if passed calldata is too short or points out of bounds. Note that dirty higher order bits are still simply ignored.
Forward all available gas with external function calls starting from Tangerine Whistle.
Semantic and Syntactic Changes
ripemd160()now accept only a single bytes argument. Moreover, the argument is not padded. This was changed to make more explicit and clear how the arguments are concatenated. Change every
.call()(and family) to a
.call(signature, a, b, c)to use
.call(abi.encodeWithSignature(signature, a, b, c))(the last one only works for value types). Change every
keccak256(a, b, c)to
keccak256(abi.encodePacked(a, b, c)). Even though it is not a breaking change, it is suggested that developers change
x.call(bytes4(keccak256("f(uint256)"), a, b)to
x.call(abi.encodeWithSignature("f(uint256)", a, b)).
(bool, bytes memory)to provide access to the return data. Change
bool success = otherContract.call("f")to
(bool success, bytes memory data) = otherContract.call("f").
Solidity now implements C99-style scoping rules for function local variables, that is, variables can only be used after they have been declared and only in the same or nested scopes. Variables declared in the initialization block of a for loop are valid at any point inside the loop.
For Solidity questions that do not pertain to a specific version, please use the general