mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests, Docs and Changelog
This commit is contained in:
@@ -2382,7 +2382,7 @@ BOOST_AUTO_TEST_CASE(generic_call)
|
||||
function doSend(address rec) public returns (uint d)
|
||||
{
|
||||
bytes4 signature = bytes4(bytes32(keccak256("recv(uint256)")));
|
||||
rec.call.value(2)(abi.encodeWithSelector(signature, 23));
|
||||
rec.call{value: 2}(abi.encodeWithSelector(signature, 23));
|
||||
return receiver(rec).received();
|
||||
}
|
||||
}
|
||||
@@ -5210,7 +5210,7 @@ BOOST_AUTO_TEST_CASE(failed_create)
|
||||
constructor() public payable {}
|
||||
function f(uint amount) public returns (D) {
|
||||
x++;
|
||||
return (new D).value(amount)();
|
||||
return (new D){value: amount}();
|
||||
}
|
||||
function stack(uint depth) public returns (address) {
|
||||
if (depth < 1024)
|
||||
@@ -5278,7 +5278,7 @@ BOOST_AUTO_TEST_CASE(mutex)
|
||||
// NOTE: It is very bad practice to write this function this way.
|
||||
// Please refer to the documentation of how to do this properly.
|
||||
if (amount > shares) revert();
|
||||
(bool success,) = msg.sender.call.value(amount)("");
|
||||
(bool success,) = msg.sender.call{value: amount}("");
|
||||
require(success);
|
||||
shares -= amount;
|
||||
return shares;
|
||||
@@ -5287,7 +5287,7 @@ BOOST_AUTO_TEST_CASE(mutex)
|
||||
// NOTE: It is very bad practice to write this function this way.
|
||||
// Please refer to the documentation of how to do this properly.
|
||||
if (amount > shares) revert();
|
||||
(bool success,) = msg.sender.call.value(amount)("");
|
||||
(bool success,) = msg.sender.call{value: amount}("");
|
||||
require(success);
|
||||
shares -= amount;
|
||||
return shares;
|
||||
|
||||
@@ -12,7 +12,7 @@ contract C {
|
||||
}
|
||||
|
||||
function g() public returns (uint256) {
|
||||
d.g.gas(200)();
|
||||
d.g{gas: 200}();
|
||||
return 7;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ contract test {
|
||||
}
|
||||
|
||||
function sendAmount(uint256 amount) public payable returns (uint256 bal) {
|
||||
return h.getBalance.value(amount)();
|
||||
return h.getBalance{value: amount}();
|
||||
}
|
||||
|
||||
function outOfGas() public returns (bool ret) {
|
||||
h.setFlag.gas(2)(); // should fail due to OOG
|
||||
h.setFlag{gas: 2}(); // should fail due to OOG
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ contract Main {
|
||||
Helper h;
|
||||
|
||||
constructor() public payable {
|
||||
h = (new Helper).value(10)("abc", true);
|
||||
h = (new Helper){value: 10}("abc", true);
|
||||
}
|
||||
|
||||
function getFlag() public returns (bool ret) {
|
||||
|
||||
@@ -14,7 +14,7 @@ contract test {
|
||||
|
||||
function sendAmount(uint256 amount) public payable returns (uint256 bal) {
|
||||
uint256 someStackElement = 20;
|
||||
return h.getBalance.value(amount).gas(1000).value(amount + 3)();
|
||||
return h.getBalance{value: amount + 3, gas: 1000}();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ contract test {
|
||||
}
|
||||
|
||||
function sendAmount(uint256 amount) public returns (uint256 bal) {
|
||||
return h.getBalance.value(amount).gas(1000).value(amount + 3)(); // overwrite value
|
||||
return h.getBalance{value: amount + 3, gas: 1000}();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,8 @@ pragma experimental SMTChecker;
|
||||
contract C {
|
||||
function f(function(uint) external payable g) internal {
|
||||
g.selector;
|
||||
g.gas(2).value(3)(4);
|
||||
g{gas: 2, value: 3}(4);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (122-127): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// Warning: (122-136): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// Warning: (108-118): Assertion checker does not yet support this expression.
|
||||
// Warning: (122-130): Assertion checker does not yet implement this type of function call.
|
||||
// Warning: (122-139): Assertion checker does not yet implement this type of function call.
|
||||
|
||||
@@ -4,7 +4,6 @@ contract C {
|
||||
this.foo{value:2, gas: 5}{gas:2};
|
||||
(this.foo{value:2, gas: 5}){gas:2};
|
||||
this.foo{value:2, gas: 5}{value:6};
|
||||
this.foo.value(4){value:2, gas: 5};
|
||||
this.foo{gas:2, value: 5}{value:2, gas:5};
|
||||
new D{salt:"abc"}{salt:"a"}();
|
||||
}
|
||||
@@ -15,8 +14,6 @@ contract C {
|
||||
// TypeError: (78-110): Option "gas" has already been set.
|
||||
// TypeError: (120-154): Option "gas" has already been set.
|
||||
// TypeError: (164-198): Option "value" has already been set.
|
||||
// Warning: (208-222): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// TypeError: (208-242): Option "value" has already been set.
|
||||
// TypeError: (252-293): Option "value" has already been set.
|
||||
// TypeError: (252-293): Option "gas" has already been set.
|
||||
// TypeError: (303-330): Option "salt" has already been set.
|
||||
// TypeError: (208-249): Option "value" has already been set.
|
||||
// TypeError: (208-249): Option "gas" has already been set.
|
||||
// TypeError: (259-286): Option "salt" has already been set.
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
contract C {
|
||||
function (uint) external returns (uint) x;
|
||||
function f() public {
|
||||
x.value(2)(1);
|
||||
x{value: 2}(1);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (94-101): Member "value" is only available for payable functions.
|
||||
// TypeError: (94-105): Cannot set option "value" on a non-payable function type.
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (102-107): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// TypeError: (102-107): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
+1
-1
@@ -8,4 +8,4 @@ contract D {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (122-135): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// TypeError: (122-135): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
+1
-1
@@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (102-109): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// TypeError: (102-109): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
+1
-4
@@ -1,10 +1,7 @@
|
||||
contract test {
|
||||
function f() public {
|
||||
address(0x12).call.value(2)("abc");
|
||||
address(0x12).call{value: 2}("abc");
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (50-74): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// Warning: (50-84): Return value of low-level calls not used.
|
||||
// Warning: (94-129): Return value of low-level calls not used.
|
||||
// Warning: (50-85): Return value of low-level calls not used.
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
contract receiver { function pay() payable public {} }
|
||||
contract test {
|
||||
function f() public { (new receiver()).pay{value: 10}(); }
|
||||
function g() public { (new receiver()).pay.value(10)(); }
|
||||
receiver r = new receiver();
|
||||
function h() public { r.pay{value: 10}(); }
|
||||
function i() public { r.pay.value(10)(); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (160-186): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// Warning: (303-314): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
|
||||
@@ -3,9 +3,9 @@ contract C {
|
||||
}
|
||||
contract D {
|
||||
function f() public returns (uint) {
|
||||
(new C).value(2)();
|
||||
(new C){value: 2}();
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (106-119): Constructor for contract C must be payable for member "value" to be available.
|
||||
// TypeError: (106-123): Cannot set option "value", since the constructor of contract C is not payable.
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
contract C {
|
||||
function f() external payable {}
|
||||
function g(address a) external pure {
|
||||
a.call.value(42);
|
||||
a.call{value: 42};
|
||||
a.call.gas(42);
|
||||
a.call{gas: 42};
|
||||
a.staticcall.gas(42);
|
||||
a.staticcall{gas: 42};
|
||||
a.delegatecall.gas(42);
|
||||
a.delegatecall{gas: 42};
|
||||
}
|
||||
function h() external view {
|
||||
this.f.value(42);
|
||||
this.f{value: 42};
|
||||
this.f.gas(42);
|
||||
this.f{gas: 42};
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (91-103): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// Warning: (132-142): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// Warning: (169-185): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// Warning: (218-236): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// Warning: (304-316): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// Warning: (345-355): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
contract C {
|
||||
function f(address a) external view returns (bool success) {
|
||||
(success,) = a.call.gas(42)("");
|
||||
(success,) = a.call{gas: 42}("");
|
||||
}
|
||||
function g(address a) external view returns (bool success) {
|
||||
(success,) = a.call.gas(42)("");
|
||||
(success,) = a.call{gas: 42}("");
|
||||
}
|
||||
function h() external payable {}
|
||||
function i() external view {
|
||||
this.h.gas(42)();
|
||||
}
|
||||
function j() external view {
|
||||
this.h{gas: 42}();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (90-100): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// Warning: (226-236): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// Warning: (351-361): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// TypeError: (90-108): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (125-144): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (226-244): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (261-280): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (351-367): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (404-421): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (90-109): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (180-197): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
|
||||
@@ -2,14 +2,10 @@ contract C {
|
||||
function f() external view {}
|
||||
function test(address a) external view returns (bool status) {
|
||||
// This used to incorrectly raise an error about violating the view mutability.
|
||||
(status,) = a.staticcall.gas(42)("");
|
||||
(status,) = a.staticcall{gas: 42}("");
|
||||
this.f.gas(42)();
|
||||
this.f{gas: 42}();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// Warning: (207-223): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
// Warning: (276-286): Using ".gas(...)" is deprecated. Use "{gas: ...}" instead.
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
contract C {
|
||||
function f(address a) external view returns (bool success) {
|
||||
(success,) = a.call.value(42)("");
|
||||
(success,) = a.call{value: 42}("");
|
||||
}
|
||||
function g(address a) external view returns (bool success) {
|
||||
(success,) = a.call.value(42)("");
|
||||
(success,) = a.call{value: 42}("");
|
||||
}
|
||||
function h() external payable {}
|
||||
function i() external view {
|
||||
this.h.value(42)();
|
||||
this.h{value: 42}();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (90-102): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// Warning: (230-242): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// Warning: (359-371): Using ".value(...)" is deprecated. Use "{value: ...}" instead.
|
||||
// TypeError: (90-110): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (127-148): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (230-250): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (267-288): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (359-377): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (381-400): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (90-111): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (182-201): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
|
||||
Reference in New Issue
Block a user