aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests/viewPureChecker
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/syntaxTests/viewPureChecker')
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol10
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol6
4 files changed, 22 insertions, 6 deletions
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
index 2cb185c9..2503a319 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
@@ -3,8 +3,10 @@ contract C {
address(this).transfer(1);
require(address(this).send(2));
selfdestruct(address(this));
- require(address(this).delegatecall(""));
- require(address(this).call(""));
+ (bool success,) = address(this).delegatecall("");
+ require(success);
+ (success,) = address(this).call("");
+ require(success);
}
function g() pure public {
bytes32 x = keccak256("abc");
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
index 9b00fd6d..f951feb4 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol
@@ -9,15 +9,17 @@ contract C {
selfdestruct(address(this));
}
function i() view public {
- require(address(this).delegatecall(""));
+ (bool success,) = address(this).delegatecall("");
+ require(success);
}
function j() view public {
- require(address(this).call(""));
+ (bool success,) = address(this).call("");
+ require(success);
}
}
// ----
// TypeError: (52-77): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
// TypeError: (132-153): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
// TypeError: (201-228): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
-// TypeError: (283-313): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
-// TypeError: (369-391): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (293-323): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// TypeError: (414-436): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
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.