aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol20
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol15
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol15
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol6
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol16
-rw-r--r--test/libsolidity/syntaxTests/variableDeclaration/do_while.sol12
-rw-r--r--test/libsolidity/syntaxTests/variableDeclaration/else.sol13
-rw-r--r--test/libsolidity/syntaxTests/variableDeclaration/for.sol11
-rw-r--r--test/libsolidity/syntaxTests/variableDeclaration/if.sol11
-rw-r--r--test/libsolidity/syntaxTests/variableDeclaration/while.sol11
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol6
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol10
12 files changed, 109 insertions, 37 deletions
diff --git a/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol
index e8134539..92ec4eb7 100644
--- a/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol
+++ b/test/libsolidity/syntaxTests/globalFunctions/call_with_wrong_arg_count.sol
@@ -1,13 +1,17 @@
contract C {
function f() public {
- require(address(this).call());
- require(address(this).call(bytes4(0x12345678)));
- require(address(this).call(uint(1)));
- require(address(this).call(uint(1), uint(2)));
+ (bool success,) = address(this).call();
+ require(success);
+ (success,) = address(this).call(bytes4(0x12345678));
+ require(success);
+ (success,) = address(this).call(uint(1));
+ require(success);
+ (success,) = address(this).call(uint(1), uint(2));
+ require(success);
}
}
// ----
-// TypeError: (55-75): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata.
-// TypeError: (113-131): Invalid type for argument in function call. Invalid implicit conversion from bytes4 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
-// TypeError: (170-177): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
-// TypeError: (197-233): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
+// TypeError: (65-85): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata.
+// TypeError: (153-171): Invalid type for argument in function call. Invalid implicit conversion from bytes4 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
+// TypeError: (240-247): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
+// TypeError: (297-333): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
diff --git a/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol
index 2b424d53..655d5f4c 100644
--- a/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol
+++ b/test/libsolidity/syntaxTests/globalFunctions/callcode_with_wrong_arg_count.sol
@@ -1,11 +1,14 @@
contract C {
function f() public {
- require(address(this).callcode());
- require(address(this).callcode(uint(1)));
- require(address(this).callcode(uint(1), uint(2)));
+ (bool success,) = address(this).callcode();
+ require(success);
+ (success,) = address(this).callcode(uint(1));
+ require(success);
+ (success,) = address(this).callcode(uint(1), uint(2));
+ require(success);
}
}
// ----
-// TypeError: (55-79): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata.
-// TypeError: (121-128): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
-// TypeError: (148-188): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
+// TypeError: (65-89): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata.
+// TypeError: (161-168): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
+// TypeError: (218-258): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
diff --git a/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol b/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol
index be0347de..fa524b99 100644
--- a/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol
+++ b/test/libsolidity/syntaxTests/globalFunctions/delegatecall_with_wrong_arg_count.sol
@@ -1,11 +1,14 @@
contract C {
function f() public {
- require(address(this).delegatecall());
- require(address(this).delegatecall(uint(1)));
- require(address(this).delegatecall(uint(1), uint(2)));
+ (bool success,) = address(this).delegatecall();
+ require(success);
+ (success,) = address(this).delegatecall(uint(1));
+ require(success);
+ (success,) = address(this).delegatecall(uint(1), uint(2));
+ require(success);
}
}
// ----
-// TypeError: (55-83): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata.
-// TypeError: (129-136): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
-// TypeError: (156-200): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
+// TypeError: (65-93): Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata.
+// TypeError: (169-176): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes memory requested. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
+// TypeError: (226-270): Wrong argument count for function call: 2 arguments given but expected 1. This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
index 9c42bc8f..b63d2a55 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/413_address_methods.sol
@@ -2,11 +2,11 @@ contract C {
function f() public {
address addr;
uint balance = addr.balance;
- bool callRet = addr.call("");
- bool delegatecallRet = addr.delegatecall("");
+ (bool callSuc,) = addr.call("");
+ (bool delegatecallSuc,) = addr.delegatecall("");
bool sendRet = addr.send(1);
addr.transfer(1);
- balance; callRet; delegatecallRet; sendRet;
+ balance; callSuc; delegatecallSuc; sendRet;
}
}
// ----
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
index c97f588e..6e0b6db4 100644
--- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
@@ -1,13 +1,13 @@
contract C {
function f() public pure {
- bool a = address(this).call(abi.encode(address(this).delegatecall, super));
- bool b = address(this).delegatecall(abi.encode(log0, tx, mulmod));
- a; b;
+ (bool a,) = address(this).call(abi.encode(address(this).delegatecall, super));
+ (a,) = address(this).delegatecall(abi.encode(log0, tx, mulmod));
+ a;
}
}
// ----
-// TypeError: (91-117): This type cannot be encoded.
-// TypeError: (119-124): This type cannot be encoded.
-// TypeError: (183-187): This type cannot be encoded.
-// TypeError: (189-191): This type cannot be encoded.
-// TypeError: (193-199): This type cannot be encoded.
+// TypeError: (94-120): This type cannot be encoded.
+// TypeError: (122-127): This type cannot be encoded.
+// TypeError: (184-188): This type cannot be encoded.
+// TypeError: (190-192): This type cannot be encoded.
+// TypeError: (194-200): This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/variableDeclaration/do_while.sol b/test/libsolidity/syntaxTests/variableDeclaration/do_while.sol
new file mode 100644
index 00000000..8fc48b33
--- /dev/null
+++ b/test/libsolidity/syntaxTests/variableDeclaration/do_while.sol
@@ -0,0 +1,12 @@
+pragma solidity >0.4.24;
+
+contract C
+{
+ function f(uint x) public pure {
+ do
+ uint y;
+ while (x > 0);
+ }
+}
+// ----
+// SyntaxError: (81-87): Variable declarations can only be used inside blocks.
diff --git a/test/libsolidity/syntaxTests/variableDeclaration/else.sol b/test/libsolidity/syntaxTests/variableDeclaration/else.sol
new file mode 100644
index 00000000..914e0c0c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/variableDeclaration/else.sol
@@ -0,0 +1,13 @@
+pragma solidity >0.4.24;
+
+contract C
+{
+ function f(uint x) public pure {
+ if (x > 0)
+ {uint y;}
+ else
+ uint z;
+ }
+}
+// ----
+// SyntaxError: (109-115): Variable declarations can only be used inside blocks.
diff --git a/test/libsolidity/syntaxTests/variableDeclaration/for.sol b/test/libsolidity/syntaxTests/variableDeclaration/for.sol
new file mode 100644
index 00000000..bc137f93
--- /dev/null
+++ b/test/libsolidity/syntaxTests/variableDeclaration/for.sol
@@ -0,0 +1,11 @@
+pragma solidity >0.4.24;
+
+contract C
+{
+ function f(uint x) public pure {
+ for (uint i = 0; i < x; ++i)
+ uint y;
+ }
+}
+// ----
+// SyntaxError: (107-113): Variable declarations can only be used inside blocks.
diff --git a/test/libsolidity/syntaxTests/variableDeclaration/if.sol b/test/libsolidity/syntaxTests/variableDeclaration/if.sol
new file mode 100644
index 00000000..75ab2026
--- /dev/null
+++ b/test/libsolidity/syntaxTests/variableDeclaration/if.sol
@@ -0,0 +1,11 @@
+pragma solidity >0.4.24;
+
+contract C
+{
+ function f(uint x) public pure {
+ if (x > 0)
+ uint y;
+ }
+}
+// ----
+// SyntaxError: (89-95): Variable declarations can only be used inside blocks.
diff --git a/test/libsolidity/syntaxTests/variableDeclaration/while.sol b/test/libsolidity/syntaxTests/variableDeclaration/while.sol
new file mode 100644
index 00000000..2997d80c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/variableDeclaration/while.sol
@@ -0,0 +1,11 @@
+pragma solidity >0.4.24;
+
+contract C
+{
+ function f(uint x) public pure {
+ while (x > 0)
+ uint y;
+ }
+}
+// ----
+// SyntaxError: (92-98): Variable declarations can only be used inside blocks.
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.