aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests/viewPureChecker
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-07-27 03:45:24 +0800
committerchriseth <chris@ethereum.org>2018-09-04 00:35:57 +0800
commit75a92b0ffd0946c17a27a58e6e02abe96cd3fa00 (patch)
tree3a7c0b7e11942266eed23e7b2a0259fd5db1a56c /test/libsolidity/syntaxTests/viewPureChecker
parent378f69160884ba23f6876d57a3eb6425bfa1d2cf (diff)
downloaddexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar
dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar.gz
dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar.bz2
dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar.lz
dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar.xz
dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar.zst
dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.zip
Warns 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.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol6
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..4cad4439
--- /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 {}
+}
+// ----
+// Warning: (118-127): "msg.value" used in non-payable function. Do you want to add the "payable" modifier to this function?