aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol14
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol7
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol7
-rw-r--r--test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number.sol14
-rw-r--r--test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number_named.sol14
-rw-r--r--test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number.sol19
-rw-r--r--test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number_named.sol19
-rw-r--r--test/libsolidity/syntaxTests/returnExpressions/valid_returns.sol18
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol11
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol10
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol10
12 files changed, 98 insertions, 48 deletions
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol
deleted file mode 100644
index 0d266ccf..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_err.sol
+++ /dev/null
@@ -1,14 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal pure returns (S storage) { return; }
- function g() internal view returns (S storage c, S storage) { c = s; return; }
- function h() internal view returns (S storage, S storage d) { d = s; return; }
- function i() internal pure returns (S storage, S storage) { return; }
-}
-// ----
-// TypeError: (87-88): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
-// TypeError: (163-164): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
-// TypeError: (233-234): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
-// TypeError: (316-317): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
-// TypeError: (327-328): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
deleted file mode 100644
index 6d72e4ef..00000000
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/emptyReturn_fine.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-contract C {
- struct S { bool f; }
- S s;
- function f() internal view returns (S storage c, S storage d) { c = s; d = s; return; }
- function g() internal view returns (S storage, S storage) { return (s,s); }
-}
-// ----
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol
index 0b171560..7567f694 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/tuple_fine.sol
@@ -8,5 +8,8 @@ contract C {
uint a;
(c, a) = f();
}
+ function h() internal view returns (S storage, S storage) {
+ return (s,s);
+ }
}
// ----
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol
deleted file mode 100644
index af67f491..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/440_warn_unused_return_parameter_with_explicit_return.sol
+++ /dev/null
@@ -1,7 +0,0 @@
-contract C {
- function f() pure public returns (uint a) {
- return;
- }
-}
-// ----
-// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning.
diff --git a/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number.sol b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number.sol
new file mode 100644
index 00000000..9741fdfb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number.sol
@@ -0,0 +1,14 @@
+contract C
+{
+ function f() public pure returns (uint)
+ {
+ return;
+ }
+ function g() public pure returns (uint)
+ {
+ return (1, 2);
+ }
+}
+// ----
+// TypeError: (71-78): Return arguments required.
+// TypeError: (143-156): Different number of arguments in return statement than in returns declaration.
diff --git a/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number_named.sol b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number_named.sol
new file mode 100644
index 00000000..53f2d994
--- /dev/null
+++ b/test/libsolidity/syntaxTests/returnExpressions/single_return_mismatching_number_named.sol
@@ -0,0 +1,14 @@
+contract C
+{
+ function f() public pure returns (uint a)
+ {
+ return;
+ }
+ function g() public pure returns (uint a)
+ {
+ return (1, 2);
+ }
+}
+// ----
+// TypeError: (73-80): Return arguments required.
+// TypeError: (147-160): Different number of arguments in return statement than in returns declaration.
diff --git a/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number.sol b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number.sol
new file mode 100644
index 00000000..4ea61c68
--- /dev/null
+++ b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number.sol
@@ -0,0 +1,19 @@
+contract C
+{
+ function f() public pure returns (uint, uint)
+ {
+ return 1;
+ }
+ function g() public pure returns (uint, uint)
+ {
+ return (1, 2, 3);
+ }
+ function h() public pure returns (uint, uint)
+ {
+ return;
+ }
+}
+// ----
+// TypeError: (77-85): Different number of arguments in return statement than in returns declaration.
+// TypeError: (157-173): Different number of arguments in return statement than in returns declaration.
+// TypeError: (245-252): Return arguments required.
diff --git a/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number_named.sol b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number_named.sol
new file mode 100644
index 00000000..86049719
--- /dev/null
+++ b/test/libsolidity/syntaxTests/returnExpressions/tuple_return_mismatching_number_named.sol
@@ -0,0 +1,19 @@
+contract C
+{
+ function f() public pure returns (uint a, uint b)
+ {
+ return 1;
+ }
+ function g() public pure returns (uint a, uint b)
+ {
+ return (1, 2, 3);
+ }
+ function h() public pure returns (uint a, uint b)
+ {
+ return;
+ }
+}
+// ----
+// TypeError: (81-89): Different number of arguments in return statement than in returns declaration.
+// TypeError: (165-181): Different number of arguments in return statement than in returns declaration.
+// TypeError: (257-264): Return arguments required.
diff --git a/test/libsolidity/syntaxTests/returnExpressions/valid_returns.sol b/test/libsolidity/syntaxTests/returnExpressions/valid_returns.sol
new file mode 100644
index 00000000..e30f9173
--- /dev/null
+++ b/test/libsolidity/syntaxTests/returnExpressions/valid_returns.sol
@@ -0,0 +1,18 @@
+contract C
+{
+ function f() public pure {
+ return;
+ }
+ function g() public pure returns (uint) {
+ return 1;
+ }
+ function h() public pure returns (uint a) {
+ return 1;
+ }
+ function i() public pure returns (uint, uint) {
+ return (1, 2);
+ }
+ function j() public pure returns (uint a, uint b) {
+ return (1, 2);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol
new file mode 100644
index 00000000..3cff3a9a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol
@@ -0,0 +1,11 @@
+// This used to crash in certain compiler versions.
+contract CrashContract {
+ struct S { uint a; }
+ S x;
+ function f() public {
+ (x, x) = 1(x, x);
+ }
+}
+// ----
+// TypeError: (170-177): Type is not callable
+// TypeError: (170-177): Type tuple() is not implicitly convertible to expected type tuple(struct CrashContract.S storage ref,struct CrashContract.S storage ref).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol
deleted file mode 100644
index 902d8b98..00000000
--- a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_left.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- (,x, y) = (1, 2, y, x);
- }
-}
-// ----
-// TypeError: (89-101): Type tuple(int_const 1,int_const 2,struct C.S storage ref,struct C.S storage ref) is not implicitly convertible to expected type tuple(,struct C.S storage ref,struct C.S storage ref).
-// Warning: (79-101): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol b/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol
deleted file mode 100644
index 51556aab..00000000
--- a/test/libsolidity/syntaxTests/tupleAssignments/err_multiple_storage_storage_copies_fill_right.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-contract C {
- struct S { uint a; uint b; }
- S x; S y;
- function f() public {
- (x, y, ) = (y, x, 1, 2);
- }
-}
-// ----
-// TypeError: (90-102): Type tuple(struct C.S storage ref,struct C.S storage ref,int_const 1,int_const 2) is not implicitly convertible to expected type tuple(struct C.S storage ref,struct C.S storage ref,).
-// Warning: (79-102): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.