aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-23 23:35:00 +0800
committerGitHub <noreply@github.com>2018-04-23 23:35:00 +0800
commite685f9f59ecf13210eb7a32156d556a4cdd8ff58 (patch)
treeaf376d07e441f26afbca94586e4e3b69ac517d30 /test/libsolidity/syntaxTests
parentc7ee2ca0b9eb6c36ddb15b70f341975bdff47aad (diff)
parent896018c8a33f92e9dd507b462c858dbcf13d6385 (diff)
downloaddexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar.gz
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar.bz2
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar.lz
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar.xz
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar.zst
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.zip
Merge pull request #3976 from ethereum/emptyTupleComponent
Empty tuple components should not be possible
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_event.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_function.sol12
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol13
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol11
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol11
7 files changed, 78 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
new file mode 100644
index 00000000..3e40b155
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
@@ -0,0 +1,10 @@
+pragma solidity ^0.4.3;
+contract C {
+ event SomeEvent();
+ function a() public {
+ (SomeEvent(), 7);
+ }
+}
+// ----
+// Warning: (95-106): Invoking events without "emit" prefix is deprecated.
+// Warning: (95-106): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol
new file mode 100644
index 00000000..aec5ff2a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_event_050.sol
@@ -0,0 +1,10 @@
+pragma experimental "v0.5.0";
+contract C {
+ event SomeEvent();
+ function a() public {
+ (SomeEvent(), 7);
+ }
+}
+// ----
+// TypeError: (101-112): Event invocations have to be prefixed by "emit".
+// TypeError: (101-112): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol
new file mode 100644
index 00000000..05b54442
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol
@@ -0,0 +1,12 @@
+pragma solidity ^0.4.3;
+contract C {
+ function f() private pure {}
+ function a() public pure {
+ bool x = true;
+ bool y = true;
+ (x) ? (f(), y = false) : (f(), y = false);
+ }
+}
+// ----
+// Warning: (162-165): Tuple component cannot be empty.
+// Warning: (181-184): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol
new file mode 100644
index 00000000..c4b9e03f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_function_050.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() private pure {}
+ function a() public pure {
+ bool x = true;
+ bool y = true;
+ (x) ? (f(), y = false) : (f(), y = false);
+ }
+}
+// ----
+// TypeError: (168-171): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol
new file mode 100644
index 00000000..cba30c1b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol
@@ -0,0 +1,13 @@
+pragma solidity ^0.4.3;
+contract C {
+ function f() private pure {}
+ function a() public {
+ uint x;
+ uint y;
+ (x, y) = (f(), f());
+ }
+}
+// ----
+// Warning: (146-149): Tuple component cannot be empty.
+// Warning: (151-154): Tuple component cannot be empty.
+// TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256).
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol
new file mode 100644
index 00000000..b0691778
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_050.sol
@@ -0,0 +1,11 @@
+pragma experimental "v0.5.0";
+contract C {
+ function f() private pure {}
+ function a() public {
+ uint x;
+ uint y;
+ (x, y) = (f(), f());
+ }
+}
+// ----
+// TypeError: (152-155): Tuple component cannot be empty.
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol
new file mode 100644
index 00000000..f8b2ae7e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol
@@ -0,0 +1,11 @@
+pragma solidity ^0.4.3;
+contract C {
+ function f() private pure {}
+ function a() public {
+ uint x;
+ uint y;
+ (x, y) = [f(), f()];
+ }
+}
+// ----
+// TypeError: (146-149): Array component cannot be empty.