From d62476fb1f3c0e9399c413c988d50feb50821ef1 Mon Sep 17 00:00:00 2001 From: D-Nice Date: Wed, 27 Jun 2018 19:42:46 -0400 Subject: Adds storage_reference.sol syntax test --- .../syntaxTests/inlineAssembly/storage_reference.sol | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol new file mode 100644 index 00000000..7b56102f --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -0,0 +1,11 @@ +contract C { + uint[] x; + function() { + uint[] storage y = x; + assembly { + pop(y) + } + } +} +// ---- +// TypeError: (110-111): You have to use the _slot or _offset suffix to access storage reference variables. -- cgit v1.2.3 From 3cad417710bc95a66d801a432f33c3befee390c9 Mon Sep 17 00:00:00 2001 From: D-Nice Date: Thu, 28 Jun 2018 16:45:53 -0400 Subject: Add passing test case --- .../syntaxTests/inlineAssembly/storage_reference.sol | 4 ++-- .../syntaxTests/inlineAssembly/storage_reference_fine.sol | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index 7b56102f..55c83674 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() { + function() public { uint[] storage y = x; assembly { pop(y) @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError: (110-111): You have to use the _slot or _offset suffix to access storage reference variables. +// TypeError: (117-118): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol new file mode 100644 index 00000000..3ae24b34 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -0,0 +1,11 @@ +contract C { + uint[] x; + function() public { + uint[] storage y = x; + assembly { + pop(y_slot) + pop(y_offset) + } + } +} +// ---- -- cgit v1.2.3 From 2211739fc4548c70be887d6666430a25b66a3bb8 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 28 Jun 2018 18:09:27 +0200 Subject: Update tests. --- test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol | 4 ++-- .../libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index 55c83674..b6dd12b8 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() public { + function() external { uint[] storage y = x; assembly { pop(y) @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError: (117-118): You have to use the _slot or _offset suffix to access storage reference variables. +// TypeError: (119-120): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol index 3ae24b34..84f98ed9 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() public { + function() external { uint[] storage y = x; assembly { pop(y_slot) -- cgit v1.2.3 From d647761058e3bb4b32846bd8b51f2de72fb85169 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 24 Jul 2018 00:36:39 +0100 Subject: Add more comprehensive tests for embedded inline assembly LValue/RValue access --- .../syntaxTests/inlineAssembly/assignment_from_contract.sol | 9 +++++++++ .../inlineAssembly/assignment_from_functiontype.sol | 7 +++++++ .../syntaxTests/inlineAssembly/assignment_from_library.sol | 10 ++++++++++ .../syntaxTests/inlineAssembly/assignment_from_super.sol | 9 +++++++++ .../syntaxTests/inlineAssembly/assignment_to_special.sol | 13 +++++++++++++ .../inlineAssembly/storage_reference_assignment.sol | 13 +++++++++++++ .../inlineAssembly/storage_reference_on_memory.sol | 13 +++++++++++++ 7 files changed, 74 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') 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/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. -- cgit v1.2.3 From ab3978723ad5651832ec49f9217882bf0b14d981 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 24 Jul 2018 01:14:45 +0100 Subject: Add more tests for inlineasm/AsmAnalyzer --- .../function_call_invalid_argument_count.sol | 16 ++++++++++++++++ .../inlineAssembly/function_call_not_found.sol | 9 +++++++++ .../inlineAssembly/function_call_to_label.sol | 13 +++++++++++++ .../inlineAssembly/function_call_to_variable.sol | 11 +++++++++++ .../syntaxTests/inlineAssembly/function_without_call.sol | 11 +++++++++++ 5 files changed, 60 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/function_call_not_found.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/function_call_to_variable.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/function_without_call.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') 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. -- cgit v1.2.3 From 8781990ff3a70934d5dcfad50cfb645fe3473c94 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 1 Aug 2018 21:57:12 +0200 Subject: Remove trailing whitespace in all contract files. --- test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol | 4 ++-- .../syntaxTests/inlineAssembly/storage_reference_assignment.sol | 6 +++--- .../syntaxTests/inlineAssembly/storage_reference_fine.sol | 2 +- .../syntaxTests/inlineAssembly/storage_reference_on_memory.sol | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index b6dd12b8..07113093 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { pop(y) @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError: (119-120): You have to use the _slot or _offset suffix to access storage reference variables. +// TypeError: (118-119): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol index d5c8eaf5..dc742142 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { y_slot := 1 @@ -9,5 +9,5 @@ contract C { } } // ---- -// TypeError: (115-121): Storage variables cannot be assigned to. -// TypeError: (139-147): Storage variables cannot be assigned to. +// TypeError: (114-120): Storage variables cannot be assigned to. +// TypeError: (138-146): Storage variables cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol index 84f98ed9..b01a7705 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { pop(y_slot) diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol index 4025e11c..704b712d 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] memory y = x; assembly { pop(y_slot) @@ -9,5 +9,5 @@ contract C { } } // ---- -// 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. +// TypeError: (117-123): The suffixes _offset and _slot can only be used on storage variables. +// TypeError: (141-149): The suffixes _offset and _slot can only be used on storage variables. -- cgit v1.2.3 From 9b8a05ebfb34b0c4062cc6ab824b7281066424a6 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 9 Jul 2018 15:04:27 +0200 Subject: Update tests to remove support for loose assembly --- .../inlineAssembly/function_call_invalid_argument_count.sol | 4 ++-- .../libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol index cbea8991..ac1f541e 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol @@ -11,6 +11,6 @@ contract C { } // ---- // 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. +// SyntaxError: (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. +// SyntaxError: (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_to_label.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol index 5de492e1..150fb938 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol @@ -8,6 +8,6 @@ contract C { } } // ---- -// 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. +// SyntaxError: (63-64): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead. +// SyntaxError: (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. -- cgit v1.2.3 From 296ba24f7f14811c5a5482457391d4f1afa49a87 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 7 Aug 2018 11:23:00 +0100 Subject: Do not crash on using _slot and _offset suffixes on their own --- .../inlineAssembly/storage_reference_empty_offset.sol | 9 +++++++++ .../syntaxTests/inlineAssembly/storage_reference_empty_slot.sol | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol new file mode 100644 index 00000000..ec23a263 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_offset.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + _offset + } + } +} +// ---- +// DeclarationError: (75-82): In variable names _slot and _offset can only be used as a suffix. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol new file mode 100644 index 00000000..d493a68a --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_empty_slot.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + assembly { + _slot + } + } +} +// ---- +// DeclarationError: (75-80): In variable names _slot and _offset can only be used as a suffix. -- cgit v1.2.3 From eb7b3862ac5089615710d07c9a56b8edc0472394 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 7 Aug 2018 12:13:52 +0100 Subject: Properly handle invalid references used together with _slot and _offset. --- .../syntaxTests/inlineAssembly/storage_reference_on_function.sol | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol new file mode 100644 index 00000000..6838e7a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol @@ -0,0 +1,9 @@ +contract C { + function f() pure public { + assembly { + let x := f_slot + } + } +} +// ---- +// DeclarationError: (84-90): Identifier not found. -- cgit v1.2.3 From 05cc7e79e1bf484c71ce93510fbfbf2c3e415cc6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 7 Aug 2018 13:17:56 +0100 Subject: More precise error message if using non-variables with _slot/_offset --- .../syntaxTests/inlineAssembly/storage_reference_on_function.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol index 6838e7a4..9165654f 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// DeclarationError: (84-90): Identifier not found. +// TypeError: (84-90): The suffixes _offset and _slot can only be used on storage variables. -- cgit v1.2.3 From 3c791d637d6bdf709ec272e6c8cf9ff51abd34ef Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 8 Aug 2018 15:55:41 +0100 Subject: Provide nicer error message when referencing overloaded references --- .../syntaxTests/inlineAssembly/overloaded_reference.sol | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol new file mode 100644 index 00000000..d1bcc946 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol @@ -0,0 +1,11 @@ +contract C { + function f() pure public {} + function f(address) pure public {} + function g() pure public { + assembly { + let x := f + } + } +} +// ---- +// DeclarationError: (155-156): Multiple matching identifiers. Resolving overloaded identifiers is not supported. -- cgit v1.2.3 From a9a414bd0f6ba89bfd719ea6b6c8501861e0ece6 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 24 Oct 2018 14:29:33 +0200 Subject: Added some tests. --- .../syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol | 13 +++++++++++++ .../inlineAssembly/invalid/empty_function_name.sol | 10 ++++++++++ .../syntaxTests/inlineAssembly/invalid/invalid_number.sol | 10 ++++++++++ .../inlineAssembly/invalid/missing_variable_in_assign.sol | 11 +++++++++++ 4 files changed, 44 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_function_name.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/missing_variable_in_assign.sol (limited to 'test/libsolidity/syntaxTests/inlineAssembly') diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol new file mode 100644 index 00000000..e05277de --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_fun_arg.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + assembly { + function f(a, b) {} + f() + f(1,) + f(,1) + } + } +} +// ---- +// ParserError: (113-114): Literal, identifier or instruction expected. +// ParserError: (113-114): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_function_name.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_function_name.sol new file mode 100644 index 00000000..17995b09 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/empty_function_name.sol @@ -0,0 +1,10 @@ +contract C { + function f() public pure { + assembly { + function (a, b) {} + } + } +} +// ---- +// ParserError: (72-73): Expected identifier but got '(' +// ParserError: (79-80): Expected ';' but got '{' diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol new file mode 100644 index 00000000..715913de --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol @@ -0,0 +1,10 @@ +contract C { + function f() public pure { + assembly { + let x := 0100 + } + } +} +// ---- +// ParserError: (72-73): Literal, identifier or instruction expected. +// ParserError: (72-73): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/missing_variable_in_assign.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/missing_variable_in_assign.sol new file mode 100644 index 00000000..c8984333 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/missing_variable_in_assign.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + assembly { + let x := mload(0) + := 1 + } + } +} +// ---- +// ParserError: (87-88): Literal, identifier or instruction expected. +// ParserError: (87-88): Expected primary expression. -- cgit v1.2.3