aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/emit_empty.sol7
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol9
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol7
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol10
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol9
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol13
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol16
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol9
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol13
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol11
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol11
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol13
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_complex.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_invalid_token.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_simple.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol12
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/pragma_illegal.sol4
24 files changed, 195 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/emit_empty.sol b/test/libsolidity/syntaxTests/emit_empty.sol
new file mode 100644
index 00000000..819d88fe
--- /dev/null
+++ b/test/libsolidity/syntaxTests/emit_empty.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ emit;
+ }
+}
+// ----
+// ParserError: (45-46): Expected event name or path.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol
new file mode 100644
index 00000000..a87a3e66
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ assembly {
+ let x := C
+ }
+ }
+}
+// ----
+// TypeError: (72-73): Expected a library.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol
new file mode 100644
index 00000000..ecda3e99
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ assembly {
+ let x := f
+ }
+ }
+}
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol
new file mode 100644
index 00000000..3c551c18
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol
@@ -0,0 +1,10 @@
+library L {
+}
+
+contract C {
+ function f() public pure {
+ assembly {
+ let x := L
+ }
+ }
+}
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol
new file mode 100644
index 00000000..bd5562d5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ assembly {
+ let x := super
+ }
+ }
+}
+// ----
+// DeclarationError: (72-77): Identifier not found.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol
new file mode 100644
index 00000000..db28e507
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public {
+ assembly {
+ super := 1
+ f := 1
+ C := 1
+ }
+ }
+}
+// ----
+// TypeError: (58-63): Only local variables can be assigned to in inline assembly.
+// TypeError: (75-76): Only local variables can be assigned to in inline assembly.
+// TypeError: (88-89): Only local variables can be assigned to in inline assembly.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
new file mode 100644
index 00000000..cbea8991
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol
@@ -0,0 +1,16 @@
+contract C {
+ function f() public pure {
+ assembly {
+ function f(a) {}
+
+ f()
+ f(1)
+ f(1, 2)
+ }
+ }
+}
+// ----
+// TypeError: (87-88): Expected 1 arguments but got 0.
+// Warning: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them.
+// TypeError: (108-109): Expected 1 arguments but got 2.
+// Warning: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol
new file mode 100644
index 00000000..57534bd6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ assembly {
+ k()
+ }
+ }
+}
+// ----
+// DeclarationError: (63-64): Function not found.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
new file mode 100644
index 00000000..5de492e1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public pure {
+ assembly {
+ l:
+
+ l()
+ }
+ }
+}
+// ----
+// Warning: (63-64): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
+// Warning: (63-64): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
+// TypeError: (73-74): Attempt to call label instead of function.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol
new file mode 100644
index 00000000..c0071855
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public pure {
+ assembly {
+ let x := 1
+
+ x()
+ }
+ }
+}
+// ----
+// TypeError: (81-82): Attempt to call variable instead of function.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol
new file mode 100644
index 00000000..8557e2fa
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public pure {
+ assembly {
+ function k() {}
+
+ k
+ }
+ }
+}
+// ----
+// TypeError: (86-87): Function k used without being called.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol
new file mode 100644
index 00000000..d5c8eaf5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol
@@ -0,0 +1,13 @@
+contract C {
+ uint[] x;
+ function() external {
+ uint[] storage y = x;
+ assembly {
+ y_slot := 1
+ y_offset := 2
+ }
+ }
+}
+// ----
+// TypeError: (115-121): Storage variables cannot be assigned to.
+// TypeError: (139-147): Storage variables cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol
new file mode 100644
index 00000000..4025e11c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol
@@ -0,0 +1,13 @@
+contract C {
+ uint[] x;
+ function() external {
+ uint[] memory y = x;
+ assembly {
+ pop(y_slot)
+ pop(y_offset)
+ }
+ }
+}
+// ----
+// TypeError: (118-124): The suffixes _offset and _slot can only be used on storage variables.
+// TypeError: (142-150): The suffixes _offset and _slot can only be used on storage variables.
diff --git a/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol b/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol
new file mode 100644
index 00000000..28a07e63
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() public pure {
+ assembly "evmasm" {}
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol b/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol
new file mode 100644
index 00000000..c2d39279
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ assembly "failasm" {}
+ }
+}
+// ----
+// ParserError: (55-64): Only "evmasm" supported.
diff --git a/test/libsolidity/syntaxTests/parsing/import_complex.sol b/test/libsolidity/syntaxTests/parsing/import_complex.sol
new file mode 100644
index 00000000..8bbb0a88
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_complex.sol
@@ -0,0 +1,3 @@
+import {hello, world} from "hello";
+// ----
+// ParserError: (0-35): Source "hello" not found: File not supplied initially.
diff --git a/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol b/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol
new file mode 100644
index 00000000..c4667606
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol
@@ -0,0 +1,3 @@
+import {hello, world} from function;
+// ----
+// ParserError: (27-35): Expected import path.
diff --git a/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol b/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol
new file mode 100644
index 00000000..961acb22
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol
@@ -0,0 +1,3 @@
+import {hello, world};
+// ----
+// ParserError: (21-22): Expected "from".
diff --git a/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol b/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol
new file mode 100644
index 00000000..df837e28
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol
@@ -0,0 +1,3 @@
+import function;
+// ----
+// ParserError: (7-15): Expected string literal (path), "*" or alias list.
diff --git a/test/libsolidity/syntaxTests/parsing/import_simple.sol b/test/libsolidity/syntaxTests/parsing/import_simple.sol
new file mode 100644
index 00000000..5d61a8bb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_simple.sol
@@ -0,0 +1,3 @@
+import "hello";
+// ----
+// ParserError: (0-15): Source "hello" not found: File not supplied initially.
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol
new file mode 100644
index 00000000..d53208ef
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol
@@ -0,0 +1,12 @@
+contract Foo {
+ uint[] m_x;
+ function f() public view {
+ uint[] storage memory x = m_x;
+ uint[] memory storage calldata y;
+ x; y;
+ }
+}
+// ----
+// ParserError: (85-91): Location already specified.
+// ParserError: (123-130): Location already specified.
+// ParserError: (131-139): Location already specified.
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol
new file mode 100644
index 00000000..c6155c09
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol
@@ -0,0 +1,6 @@
+contract Foo {
+ function f(uint[] storage memory constant x, uint[] memory calldata y) internal { }
+}
+// ----
+// ParserError: (45-51): Location already specified.
+// ParserError: (78-86): Location already specified.
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol
new file mode 100644
index 00000000..e34df2b2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol
@@ -0,0 +1,5 @@
+contract Foo {
+ uint[] memory storage calldata x;
+}
+// ----
+// ParserError: (23-29): Expected identifier but got 'memory'
diff --git a/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol b/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol
new file mode 100644
index 00000000..3395f6be
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol
@@ -0,0 +1,4 @@
+pragma ``;
+// ----
+// ParserError: (7-8): Token incompatible with Solidity parser as part of pragma directive.
+// ParserError: (8-9): Token incompatible with Solidity parser as part of pragma directive.