diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-05-08 20:26:01 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-05-17 00:32:47 +0800 |
commit | 5c59d56335f3777b9e4ad595b66787ed563b26f1 (patch) | |
tree | 3099b0f30601a86f030710d8805758a31cee54b3 /docs/types.rst | |
parent | 76fc4f8e00a994f0d961d2ca5f0eafa500b20e8e (diff) | |
download | dexon-solidity-5c59d56335f3777b9e4ad595b66787ed563b26f1.tar.gz dexon-solidity-5c59d56335f3777b9e4ad595b66787ed563b26f1.tar.zst dexon-solidity-5c59d56335f3777b9e4ad595b66787ed563b26f1.zip |
Disallow conversions between bytesX and uintY of different size.
Diffstat (limited to 'docs/types.rst')
-rw-r--r-- | docs/types.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/types.rst b/docs/types.rst index 5c20dc67..63cdbe05 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -975,6 +975,15 @@ cut off:: uint32 a = 0x12345678; uint16 b = uint16(a); // b will be 0x5678 now +Since 0.5.0 explicit conversions between integers and fixed-size byte arrays +are only allowed, if both have the same size. To convert between integers and +fixed-size byte arrays of different size, they first have to be explicitly +converted to a matching size. This makes alignment and padding explicit:: + + uint16 x = 0xffff; + bytes32(uint256(x)); // pad on the left + bytes32(bytes2(x)); // pad on the right + .. index:: ! type;deduction, ! var .. _type-deduction: |