solidity/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
2022-04-01 23:41:18 -05:00

28 lines
1.2 KiB
Solidity

contract C {
function f() view public {
payable(this).transfer(1);
}
function g() view public {
require(payable(this).send(2));
}
function h() view public {
selfdestruct(payable(this));
}
function i() view public {
(bool success,) = address(this).delegatecall("");
require(success);
}
function j() view public {
(bool success,) = address(this).call("");
require(success);
}
receive() payable external {
}
}
// ----
// TypeError 8961: (52-77='payable(this).transfer(1)'): Function cannot be declared as view because this expression (potentially) modifies the state.
// TypeError 8961: (132-153='payable(this).send(2)'): Function cannot be declared as view because this expression (potentially) modifies the state.
// TypeError 8961: (201-228='selfdestruct(payable(this))'): Function cannot be declared as view because this expression (potentially) modifies the state.
// TypeError 8961: (293-323='address(this).delegatecall("")'): Function cannot be declared as view because this expression (potentially) modifies the state.
// TypeError 8961: (414-436='address(this).call("")'): Function cannot be declared as view because this expression (potentially) modifies the state.