-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
bug 🐛documentation 📖low effortThere is not much implementation work to be done. The task is very easy or tiny.There is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.Changes are not very noticeable or potential benefits are limited.must haveSomething we consider an essential part of Solidity 1.0.Something we consider an essential part of Solidity 1.0.
Description
So you state here:
Explicit conversions to and from
address
are allowed foruint160
, integer literals,bytes20
and contract types.
Later below, in the "Warning" section you state:
You can use
address(uint160(bytes20(b)))
...
I also have seen the address(uint160(bytes20(...)))
patterns many times in codebases. However, the bytes20
to uint160
cast is unnecessary as you even state in your docs that you can explicitly convert from bytes20
to an address
. You can simply test this:
➜ bytes32 a = keccak256("hello")
➜ address(uint160(bytes20(a)))
Type: address
└ Data: 0x1C8AFf950685C2Ed4BC3174F3472287b56D9517b
➜ address(bytes20(a))
Type: address
└ Data: 0x1C8AFf950685C2Ed4BC3174F3472287b56D9517b
➜ payable(address(bytes20(a)))
Type: address
└ Data: 0x1C8AFf950685C2Ed4BC3174F3472287b56D9517b
Patched here: #16132.
Metadata
Metadata
Assignees
Labels
bug 🐛documentation 📖low effortThere is not much implementation work to be done. The task is very easy or tiny.There is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.Changes are not very noticeable or potential benefits are limited.must haveSomething we consider an essential part of Solidity 1.0.Something we consider an essential part of Solidity 1.0.