mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow explicit conversions from negative literals to `address`
This commit is contained in:
committed by
hrkrshnn
parent
b401093679
commit
a309669f75
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() public pure returns (address) {
|
||||
return address(2**160 -1);
|
||||
}
|
||||
function g() public pure returns (address) {
|
||||
return address(uint(-1));
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f() public pure returns (address) {
|
||||
return address(-1);
|
||||
}
|
||||
function g() public pure returns (address) {
|
||||
return -1;
|
||||
}
|
||||
function h() public pure returns (address) {
|
||||
return address(2**160);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9640: (77-88): Explicit type conversion not allowed from "int_const -1" to "address".
|
||||
// TypeError 6359: (160-162): Return argument type int_const -1 is not implicitly convertible to expected type (type of first return variable) address.
|
||||
// TypeError 9640: (225-240): Explicit type conversion not allowed from "int_const 1461...(41 digits omitted)...2976" to "address".
|
||||
Reference in New Issue
Block a user