mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Set state mutability of function type members `gas and value` to pure.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f() external payable {}
|
||||
function g(address a) external pure {
|
||||
a.call.value(42);
|
||||
a.call.gas(42);
|
||||
a.staticcall.gas(42);
|
||||
a.delegatecall.gas(42);
|
||||
}
|
||||
function h() external view {
|
||||
this.f.value(42);
|
||||
this.f.gas(42);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
function f(address a) external view returns (bool success) {
|
||||
(success,) = a.call.gas(42)("");
|
||||
}
|
||||
function g(address a) external view returns (bool success) {
|
||||
(success,) = a.call.gas(42)("");
|
||||
}
|
||||
function h() external payable {}
|
||||
function i() external view {
|
||||
this.h.gas(42)();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// 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.
|
||||
@@ -0,0 +1,11 @@
|
||||
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)("");
|
||||
this.f.gas(42)();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
function f(address a) external view returns (bool success) {
|
||||
(success,) = a.call.value(42)("");
|
||||
}
|
||||
function g(address a) external view returns (bool success) {
|
||||
(success,) = a.call.value(42)("");
|
||||
}
|
||||
function h() external payable {}
|
||||
function i() external view {
|
||||
this.h.value(42)();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// 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.
|
||||
Reference in New Issue
Block a user