Merge pull request #4590 from ethereum/msgValueModifier

Warn if modifier uses msg.value in non-payable function
This commit is contained in:
chriseth
2018-09-05 10:32:10 +02:00
committed by GitHub
13 changed files with 142 additions and 66 deletions
@@ -0,0 +1,6 @@
contract C {
modifier m(uint _amount, uint _avail) { require(_avail >= _amount); _; }
function f() m(1 ether, msg.value) public pure {}
}
// ----
// TypeError: (118-127): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
@@ -0,0 +1,6 @@
contract C {
modifier m(uint _amount, uint _avail) { require(_avail >= _amount); _; }
function f() m(1 ether, msg.value) public view {}
}
// ----
// TypeError: (118-127): "msg.value" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.