Tests/Docs: changing type of msg.sender and tx.origin into address

And also making the type of address(literal) as non-payable address.
This commit is contained in:
hrkrshnn
2020-12-14 16:55:48 +01:00
parent e1a95cfd42
commit 88c99a7538
45 changed files with 159 additions and 89 deletions
@@ -4,7 +4,7 @@ contract test {
x;
}
function g() public {
suicide(0x0000000000000000000000000000000000000001);
suicide(payable(0x0000000000000000000000000000000000000001));
}
}
// ----
@@ -0,0 +1,7 @@
contract C {
function f() public {
(msg.sender).send(10);
}
}
// ----
// TypeError 9862: (47-64): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -0,0 +1,7 @@
contract C {
function f() public {
(msg.sender).transfer(10);
}
}
// ----
// TypeError 9862: (47-68): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -0,0 +1,7 @@
contract C {
function f() public {
(tx.origin).send(10);
}
}
// ----
// TypeError 9862: (47-63): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -0,0 +1,7 @@
contract C {
function f() public {
(tx.origin).transfer(10);
}
}
// ----
// TypeError 9862: (47-67): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -1,6 +1,6 @@
contract test {
function f() public {
address(0x12).send(1);
payable(0x12).send(1);
}
}
// ----
@@ -1,6 +1,6 @@
contract C {
function f() public {
(0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E).transfer(2);
payable(0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E).transfer(2);
}
}
// ----
@@ -1,3 +1,3 @@
contract C {
address payable constant a = address(0);
address payable constant a = payable(0);
}
@@ -9,7 +9,7 @@ contract C {
}
}
// ----
// TypeError 2271: (85-108): Operator + not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (122-145): Operator - not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (159-182): Operator * not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (196-219): Operator / not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (85-108): Operator + not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (122-145): Operator - not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (159-182): Operator * not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (196-219): Operator / not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
@@ -1,6 +1,6 @@
contract C {
address constant a = address(0);
address payable constant b = address(0);
address payable constant b = payable(0);
function f() public pure returns (address, address) {
return (a,b);
}
@@ -1,9 +1,9 @@
contract C {
address constant a = address(0);
address payable constant b = address(0);
address payable constant b = payable(0);
function f() public {
a = address(0);
b = address(0);
b = payable(0);
}
}
// ----
@@ -0,0 +1,9 @@
contract C {
function f() public pure {
address payable a = payable(address(0x00000000219ab540356cBB839Cbe05303d7705Fa));
address payable b = payable(0x00000000219ab540356cBB839Cbe05303d7705Fa);
a = b;
b = a;
}
}
// ----
@@ -0,0 +1,9 @@
contract C {
function f() public pure {
address payable a = address(0x00000000219ab540356cBB839Cbe05303d7705Fa);
address payable b = 0x00000000219ab540356cBB839Cbe05303d7705Fa;
}
}
// ----
// TypeError 9574: (52-123): Type address is not implicitly convertible to expected type address payable.
// TypeError 9574: (133-195): Type address is not implicitly convertible to expected type address payable.
@@ -2,7 +2,7 @@ contract C {
function f(address payable) internal pure {}
function f(address) internal pure {}
function g() internal pure {
address payable a = address(0);
address payable a = payable(0);
f(a);
}
}
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError 9574: (46-62): Type address payable is not implicitly convertible to expected type contract C.
// TypeError 9574: (46-62): Type address is not implicitly convertible to expected type contract C.
@@ -1,6 +1,6 @@
contract C {
function f() public pure returns (C c) {
c = C(address(2));
c = C(payable(2));
}
fallback() external payable {
}
@@ -1,6 +1,6 @@
contract C {
function f() public pure returns (C c) {
c = C(address(2));
c = C(payable(2));
}
receive() external payable {
}
@@ -1,6 +1,6 @@
contract C {
function f() public view returns (address payable a, address b) {
(address c, address payable d) = (address(this), address(0));
(address c, address payable d) = (address(this), payable(0));
(a,b) = (c,d);
}
}
@@ -1,6 +1,6 @@
contract C {
function f() public view returns (address payable a, address b) {
(address c, address payable d) = (address(this), address(0));
(address c, address payable d) = (address(this), payable(0));
(a,b) = (d,c);
}
}
}
@@ -0,0 +1,5 @@
contract C {
function f() public returns (bool success) {
(success, ) = (address(0)).call{value: 30}("");
}
}
@@ -1,8 +1,8 @@
contract C {
function f() public pure {
address payable a = address(0);
a = address(1);
address payable b = 0x0123456789012345678901234567890123456789;
b = 0x9876543210987654321098765432109876543210;
address payable a = payable(0);
a = payable(1);
address payable b = payable(0x0123456789012345678901234567890123456789);
b = payable(0x9876543210987654321098765432109876543210);
}
}
}
@@ -0,0 +1,7 @@
contract C {
function f() public pure {
address payable a = address(0);
}
}
// ----
// TypeError 9574: (52-82): Type address is not implicitly convertible to expected type address payable.
@@ -41,7 +41,7 @@ contract C
// TypeError 9640: (183-213): Explicit type conversion not allowed from "uint16" to "int8".
// TypeError 9640: (270-277): Explicit type conversion not allowed from "uint16" to "int8".
// TypeError 9640: (300-329): Explicit type conversion not allowed from "uint256" to "address".
// TypeError 9640: (349-365): Explicit type conversion not allowed from "address payable" to "uint256".
// TypeError 9640: (349-365): Explicit type conversion not allowed from "address" to "uint256".
// TypeError 9640: (421-431): Explicit type conversion not allowed from "uint256" to "address".
// TypeError 9640: (452-471): Explicit type conversion not allowed from "bytes10" to "int80".
// TypeError 9640: (493-511): Explicit type conversion not allowed from "int80" to "bytes10".