mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Deprecated warning for .value() and .gas() on function and constructror calls
This commit is contained in:
@@ -2,12 +2,25 @@ 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,16 +1,27 @@
|
||||
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: (190-208): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (279-295): 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.
|
||||
|
||||
@@ -3,9 +3,13 @@ contract C {
|
||||
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,16 +1,25 @@
|
||||
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: (192-212): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (283-301): 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.
|
||||
|
||||
Reference in New Issue
Block a user