diff options
author | chriseth <chris@ethereum.org> | 2018-09-05 16:32:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-05 16:32:10 +0800 |
commit | a996ea266c4542b37503c1d2261a17f3d5a55dbb (patch) | |
tree | c270b6634ff1bb1814ab5524e05ef841610007a4 /test/libsolidity/syntaxTests/viewPureChecker | |
parent | e6aa15bae1839ce6761c75521e0166c06469dc2e (diff) | |
parent | de9f566a7cda48a8a23f91be380e8cd917ecaf34 (diff) | |
download | dexon-solidity-a996ea266c4542b37503c1d2261a17f3d5a55dbb.tar dexon-solidity-a996ea266c4542b37503c1d2261a17f3d5a55dbb.tar.gz dexon-solidity-a996ea266c4542b37503c1d2261a17f3d5a55dbb.tar.bz2 dexon-solidity-a996ea266c4542b37503c1d2261a17f3d5a55dbb.tar.lz dexon-solidity-a996ea266c4542b37503c1d2261a17f3d5a55dbb.tar.xz dexon-solidity-a996ea266c4542b37503c1d2261a17f3d5a55dbb.tar.zst dexon-solidity-a996ea266c4542b37503c1d2261a17f3d5a55dbb.zip |
Merge pull request #4590 from ethereum/msgValueModifier
Warn if modifier uses msg.value in non-payable function
Diffstat (limited to 'test/libsolidity/syntaxTests/viewPureChecker')
-rw-r--r-- | test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier.sol | 6 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier.sol b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier.sol new file mode 100644 index 00000000..160b20a7 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier.sol @@ -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". diff --git a/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol new file mode 100644 index 00000000..613b0198 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol @@ -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. |