From babb175d868ca07d361c2d760d9f0c616c37aaee Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 30 Jul 2020 11:19:08 +0100 Subject: [PATCH] Add more syntax tests for Yul --- .../inlineAssembly/invalid/dup_disallowed.sol | 43 +++++++++++ .../invalid/jumpdest_disallowed.sol | 9 +++ .../invalid/push_disallowed.sol | 73 +++++++++++++++++++ .../invalid/swap_disallowed.sol | 43 +++++++++++ .../yulSyntaxTests/datacopy_shadowing.yul | 5 ++ .../yulSyntaxTests/dataoffset_shadowing.yul | 5 ++ .../yulSyntaxTests/datasize_shadowing.yul | 5 ++ .../yulSyntaxTests/invalid/dup_disallowed.yul | 39 ++++++++++ .../invalid/invalid_octal_number.yul | 5 ++ .../invalid/jump_disallowed.yul | 5 ++ .../invalid/jumpdest_disallowed.yul | 5 ++ .../invalid/jumpi_disallowed.yul | 5 ++ .../invalid/label_disallowed.yul | 5 ++ .../invalid/leave_items_on_tack.yul | 5 ++ .../invalid/literals_on_stack_disallowed.yul | 5 ++ .../{pc.yul => invalid/pc_disallowed.yul} | 0 .../invalid/push_disallowed.yul | 69 ++++++++++++++++++ .../invalid/swap_disallowed.yul | 39 ++++++++++ .../yulSyntaxTests/linkersymbol_shadowing.yul | 7 ++ .../loadimmutable_shadowing.yul | 7 ++ .../yulSyntaxTests/setimmutable_shadowing.yul | 7 ++ 21 files changed, 386 insertions(+) create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/dup_disallowed.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/jumpdest_disallowed.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/push_disallowed.sol create mode 100644 test/libsolidity/syntaxTests/inlineAssembly/invalid/swap_disallowed.sol create mode 100644 test/libyul/yulSyntaxTests/datacopy_shadowing.yul create mode 100644 test/libyul/yulSyntaxTests/dataoffset_shadowing.yul create mode 100644 test/libyul/yulSyntaxTests/datasize_shadowing.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/dup_disallowed.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/jump_disallowed.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/jumpdest_disallowed.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/jumpi_disallowed.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/label_disallowed.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/leave_items_on_tack.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/literals_on_stack_disallowed.yul rename test/libyul/yulSyntaxTests/{pc.yul => invalid/pc_disallowed.yul} (100%) create mode 100644 test/libyul/yulSyntaxTests/invalid/push_disallowed.yul create mode 100644 test/libyul/yulSyntaxTests/invalid/swap_disallowed.yul create mode 100644 test/libyul/yulSyntaxTests/linkersymbol_shadowing.yul create mode 100644 test/libyul/yulSyntaxTests/loadimmutable_shadowing.yul create mode 100644 test/libyul/yulSyntaxTests/setimmutable_shadowing.yul diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/dup_disallowed.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dup_disallowed.sol new file mode 100644 index 000000000..9d9b35e28 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/dup_disallowed.sol @@ -0,0 +1,43 @@ +contract C { + function f() pure public { + assembly { + dup0() + dup1() + dup2() + dup3() + dup4() + dup5() + dup6() + dup7() + dup8() + dup9() + dup10() + dup11() + dup12() + dup13() + dup14() + dup15() + dup16() + dup32() + } + } +} +// ---- +// DeclarationError 4619: (75-79): Function not found. +// DeclarationError 4619: (94-98): Function not found. +// DeclarationError 4619: (113-117): Function not found. +// DeclarationError 4619: (132-136): Function not found. +// DeclarationError 4619: (151-155): Function not found. +// DeclarationError 4619: (170-174): Function not found. +// DeclarationError 4619: (189-193): Function not found. +// DeclarationError 4619: (208-212): Function not found. +// DeclarationError 4619: (227-231): Function not found. +// DeclarationError 4619: (246-250): Function not found. +// DeclarationError 4619: (265-270): Function not found. +// DeclarationError 4619: (285-290): Function not found. +// DeclarationError 4619: (305-310): Function not found. +// DeclarationError 4619: (325-330): Function not found. +// DeclarationError 4619: (345-350): Function not found. +// DeclarationError 4619: (365-370): Function not found. +// DeclarationError 4619: (385-390): Function not found. +// DeclarationError 4619: (405-410): Function not found. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/jumpdest_disallowed.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/jumpdest_disallowed.sol new file mode 100644 index 000000000..7da213776 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/jumpdest_disallowed.sol @@ -0,0 +1,9 @@ +contract C { + function f() pure public { + assembly { + jumpdest() + } + } +} +// ---- +// DeclarationError 4619: (75-83): Function not found. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/push_disallowed.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/push_disallowed.sol new file mode 100644 index 000000000..72e3fcd98 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/push_disallowed.sol @@ -0,0 +1,73 @@ +contract C { + function f() pure public { + assembly { + push0() + push1() + push2() + push3() + push4() + push5() + push6() + push7() + push8() + push9() + push10() + push11() + push12() + push13() + push14() + push15() + push16() + push17() + push18() + push19() + push20() + push21() + push22() + push23() + push24() + push25() + push26() + push27() + push28() + push29() + push30() + push31() + push32() + } + } +} +// ---- +// DeclarationError 4619: (75-80): Function not found. +// DeclarationError 4619: (95-100): Function not found. +// DeclarationError 4619: (115-120): Function not found. +// DeclarationError 4619: (135-140): Function not found. +// DeclarationError 4619: (155-160): Function not found. +// DeclarationError 4619: (175-180): Function not found. +// DeclarationError 4619: (195-200): Function not found. +// DeclarationError 4619: (215-220): Function not found. +// DeclarationError 4619: (235-240): Function not found. +// DeclarationError 4619: (255-260): Function not found. +// DeclarationError 4619: (275-281): Function not found. +// DeclarationError 4619: (296-302): Function not found. +// DeclarationError 4619: (317-323): Function not found. +// DeclarationError 4619: (338-344): Function not found. +// DeclarationError 4619: (359-365): Function not found. +// DeclarationError 4619: (380-386): Function not found. +// DeclarationError 4619: (401-407): Function not found. +// DeclarationError 4619: (422-428): Function not found. +// DeclarationError 4619: (443-449): Function not found. +// DeclarationError 4619: (464-470): Function not found. +// DeclarationError 4619: (485-491): Function not found. +// DeclarationError 4619: (506-512): Function not found. +// DeclarationError 4619: (527-533): Function not found. +// DeclarationError 4619: (548-554): Function not found. +// DeclarationError 4619: (569-575): Function not found. +// DeclarationError 4619: (590-596): Function not found. +// DeclarationError 4619: (611-617): Function not found. +// DeclarationError 4619: (632-638): Function not found. +// DeclarationError 4619: (653-659): Function not found. +// DeclarationError 4619: (674-680): Function not found. +// DeclarationError 4619: (695-701): Function not found. +// DeclarationError 4619: (716-722): Function not found. +// DeclarationError 4619: (737-743): Function not found. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/swap_disallowed.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/swap_disallowed.sol new file mode 100644 index 000000000..278398218 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/swap_disallowed.sol @@ -0,0 +1,43 @@ +contract C { + function f() pure public { + assembly { + swap0() + swap1() + swap2() + swap3() + swap4() + swap5() + swap6() + swap7() + swap8() + swap9() + swap10() + swap11() + swap12() + swap13() + swap14() + swap15() + swap16() + swap32() + } + } +} +// ---- +// DeclarationError 4619: (75-80): Function not found. +// DeclarationError 4619: (95-100): Function not found. +// DeclarationError 4619: (115-120): Function not found. +// DeclarationError 4619: (135-140): Function not found. +// DeclarationError 4619: (155-160): Function not found. +// DeclarationError 4619: (175-180): Function not found. +// DeclarationError 4619: (195-200): Function not found. +// DeclarationError 4619: (215-220): Function not found. +// DeclarationError 4619: (235-240): Function not found. +// DeclarationError 4619: (255-260): Function not found. +// DeclarationError 4619: (275-281): Function not found. +// DeclarationError 4619: (296-302): Function not found. +// DeclarationError 4619: (317-323): Function not found. +// DeclarationError 4619: (338-344): Function not found. +// DeclarationError 4619: (359-365): Function not found. +// DeclarationError 4619: (380-386): Function not found. +// DeclarationError 4619: (401-407): Function not found. +// DeclarationError 4619: (422-428): Function not found. diff --git a/test/libyul/yulSyntaxTests/datacopy_shadowing.yul b/test/libyul/yulSyntaxTests/datacopy_shadowing.yul new file mode 100644 index 000000000..3f14f4722 --- /dev/null +++ b/test/libyul/yulSyntaxTests/datacopy_shadowing.yul @@ -0,0 +1,5 @@ +{ + function datacopy(a, b, c) {} +} +// ---- +// ParserError 5568: (15-23): Cannot use builtin function name "datacopy" as identifier name. diff --git a/test/libyul/yulSyntaxTests/dataoffset_shadowing.yul b/test/libyul/yulSyntaxTests/dataoffset_shadowing.yul new file mode 100644 index 000000000..fb32fb61c --- /dev/null +++ b/test/libyul/yulSyntaxTests/dataoffset_shadowing.yul @@ -0,0 +1,5 @@ +{ + function dataoffset(a) -> b {} +} +// ---- +// ParserError 5568: (15-25): Cannot use builtin function name "dataoffset" as identifier name. diff --git a/test/libyul/yulSyntaxTests/datasize_shadowing.yul b/test/libyul/yulSyntaxTests/datasize_shadowing.yul new file mode 100644 index 000000000..379401754 --- /dev/null +++ b/test/libyul/yulSyntaxTests/datasize_shadowing.yul @@ -0,0 +1,5 @@ +{ + function datasize(a) -> b {} +} +// ---- +// ParserError 5568: (15-23): Cannot use builtin function name "datasize" as identifier name. diff --git a/test/libyul/yulSyntaxTests/invalid/dup_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/dup_disallowed.yul new file mode 100644 index 000000000..ffcd60c3e --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/dup_disallowed.yul @@ -0,0 +1,39 @@ +{ + dup0() + dup1() + dup2() + dup3() + dup4() + dup5() + dup6() + dup7() + dup8() + dup9() + dup10() + dup11() + dup12() + dup13() + dup14() + dup15() + dup16() + dup32() +} +// ---- +// DeclarationError 4619: (6-10): Function not found. +// DeclarationError 4619: (17-21): Function not found. +// DeclarationError 4619: (28-32): Function not found. +// DeclarationError 4619: (39-43): Function not found. +// DeclarationError 4619: (50-54): Function not found. +// DeclarationError 4619: (61-65): Function not found. +// DeclarationError 4619: (72-76): Function not found. +// DeclarationError 4619: (83-87): Function not found. +// DeclarationError 4619: (94-98): Function not found. +// DeclarationError 4619: (105-109): Function not found. +// DeclarationError 4619: (116-121): Function not found. +// DeclarationError 4619: (128-133): Function not found. +// DeclarationError 4619: (140-145): Function not found. +// DeclarationError 4619: (152-157): Function not found. +// DeclarationError 4619: (164-169): Function not found. +// DeclarationError 4619: (176-181): Function not found. +// DeclarationError 4619: (188-193): Function not found. +// DeclarationError 4619: (200-205): Function not found. diff --git a/test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul b/test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul new file mode 100644 index 000000000..c3b5e02c2 --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul @@ -0,0 +1,5 @@ +{ + let x := 0100 +} +// ---- +// ParserError 1856: (15-16): Literal or identifier expected. diff --git a/test/libyul/yulSyntaxTests/invalid/jump_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/jump_disallowed.yul new file mode 100644 index 000000000..5ab50a4c6 --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/jump_disallowed.yul @@ -0,0 +1,5 @@ +{ + jump(2) +} +// ---- +// DeclarationError 4619: (6-10): Function not found. diff --git a/test/libyul/yulSyntaxTests/invalid/jumpdest_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/jumpdest_disallowed.yul new file mode 100644 index 000000000..579f34892 --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/jumpdest_disallowed.yul @@ -0,0 +1,5 @@ +{ + jumpdest() +} +// ---- +// DeclarationError 4619: (6-14): Function not found. diff --git a/test/libyul/yulSyntaxTests/invalid/jumpi_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/jumpi_disallowed.yul new file mode 100644 index 000000000..e22a86ce1 --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/jumpi_disallowed.yul @@ -0,0 +1,5 @@ +{ + jumpi(2, 1) +} +// ---- +// DeclarationError 4619: (6-11): Function not found. diff --git a/test/libyul/yulSyntaxTests/invalid/label_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/label_disallowed.yul new file mode 100644 index 000000000..63762bd31 --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/label_disallowed.yul @@ -0,0 +1,5 @@ +{ + label: +} +// ---- +// ParserError 6913: (11-12): Call or assignment expected. diff --git a/test/libyul/yulSyntaxTests/invalid/leave_items_on_tack.yul b/test/libyul/yulSyntaxTests/invalid/leave_items_on_tack.yul new file mode 100644 index 000000000..dca68b7a0 --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/leave_items_on_tack.yul @@ -0,0 +1,5 @@ +{ + mload(0) +} +// ---- +// TypeError 3083: (6-14): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. diff --git a/test/libyul/yulSyntaxTests/invalid/literals_on_stack_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/literals_on_stack_disallowed.yul new file mode 100644 index 000000000..f57faf32a --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/literals_on_stack_disallowed.yul @@ -0,0 +1,5 @@ +{ + 1 +} +// ---- +// ParserError 6913: (8-9): Call or assignment expected. diff --git a/test/libyul/yulSyntaxTests/pc.yul b/test/libyul/yulSyntaxTests/invalid/pc_disallowed.yul similarity index 100% rename from test/libyul/yulSyntaxTests/pc.yul rename to test/libyul/yulSyntaxTests/invalid/pc_disallowed.yul diff --git a/test/libyul/yulSyntaxTests/invalid/push_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/push_disallowed.yul new file mode 100644 index 000000000..c863e58c8 --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/push_disallowed.yul @@ -0,0 +1,69 @@ +{ + push0() + push1() + push2() + push3() + push4() + push5() + push6() + push7() + push8() + push9() + push10() + push11() + push12() + push13() + push14() + push15() + push16() + push17() + push18() + push19() + push20() + push21() + push22() + push23() + push24() + push25() + push26() + push27() + push28() + push29() + push30() + push31() + push32() +} +// ---- +// DeclarationError 4619: (6-11): Function not found. +// DeclarationError 4619: (18-23): Function not found. +// DeclarationError 4619: (30-35): Function not found. +// DeclarationError 4619: (42-47): Function not found. +// DeclarationError 4619: (54-59): Function not found. +// DeclarationError 4619: (66-71): Function not found. +// DeclarationError 4619: (78-83): Function not found. +// DeclarationError 4619: (90-95): Function not found. +// DeclarationError 4619: (102-107): Function not found. +// DeclarationError 4619: (114-119): Function not found. +// DeclarationError 4619: (126-132): Function not found. +// DeclarationError 4619: (139-145): Function not found. +// DeclarationError 4619: (152-158): Function not found. +// DeclarationError 4619: (165-171): Function not found. +// DeclarationError 4619: (178-184): Function not found. +// DeclarationError 4619: (191-197): Function not found. +// DeclarationError 4619: (204-210): Function not found. +// DeclarationError 4619: (217-223): Function not found. +// DeclarationError 4619: (230-236): Function not found. +// DeclarationError 4619: (243-249): Function not found. +// DeclarationError 4619: (256-262): Function not found. +// DeclarationError 4619: (269-275): Function not found. +// DeclarationError 4619: (282-288): Function not found. +// DeclarationError 4619: (295-301): Function not found. +// DeclarationError 4619: (308-314): Function not found. +// DeclarationError 4619: (321-327): Function not found. +// DeclarationError 4619: (334-340): Function not found. +// DeclarationError 4619: (347-353): Function not found. +// DeclarationError 4619: (360-366): Function not found. +// DeclarationError 4619: (373-379): Function not found. +// DeclarationError 4619: (386-392): Function not found. +// DeclarationError 4619: (399-405): Function not found. +// DeclarationError 4619: (412-418): Function not found. diff --git a/test/libyul/yulSyntaxTests/invalid/swap_disallowed.yul b/test/libyul/yulSyntaxTests/invalid/swap_disallowed.yul new file mode 100644 index 000000000..4103cab6f --- /dev/null +++ b/test/libyul/yulSyntaxTests/invalid/swap_disallowed.yul @@ -0,0 +1,39 @@ +{ + swap0() + swap1() + swap2() + swap3() + swap4() + swap5() + swap6() + swap7() + swap8() + swap9() + swap10() + swap11() + swap12() + swap13() + swap14() + swap15() + swap16() + swap32() +} +// ---- +// DeclarationError 4619: (6-11): Function not found. +// DeclarationError 4619: (18-23): Function not found. +// DeclarationError 4619: (30-35): Function not found. +// DeclarationError 4619: (42-47): Function not found. +// DeclarationError 4619: (54-59): Function not found. +// DeclarationError 4619: (66-71): Function not found. +// DeclarationError 4619: (78-83): Function not found. +// DeclarationError 4619: (90-95): Function not found. +// DeclarationError 4619: (102-107): Function not found. +// DeclarationError 4619: (114-119): Function not found. +// DeclarationError 4619: (126-132): Function not found. +// DeclarationError 4619: (139-145): Function not found. +// DeclarationError 4619: (152-158): Function not found. +// DeclarationError 4619: (165-171): Function not found. +// DeclarationError 4619: (178-184): Function not found. +// DeclarationError 4619: (191-197): Function not found. +// DeclarationError 4619: (204-210): Function not found. +// DeclarationError 4619: (217-223): Function not found. diff --git a/test/libyul/yulSyntaxTests/linkersymbol_shadowing.yul b/test/libyul/yulSyntaxTests/linkersymbol_shadowing.yul new file mode 100644 index 000000000..68ce920e1 --- /dev/null +++ b/test/libyul/yulSyntaxTests/linkersymbol_shadowing.yul @@ -0,0 +1,7 @@ +{ + function linkersymbol(a) {} +} +// ==== +// dialect: evm +// ---- +// ParserError 5568: (15-27): Cannot use builtin function name "linkersymbol" as identifier name. diff --git a/test/libyul/yulSyntaxTests/loadimmutable_shadowing.yul b/test/libyul/yulSyntaxTests/loadimmutable_shadowing.yul new file mode 100644 index 000000000..8711d0b17 --- /dev/null +++ b/test/libyul/yulSyntaxTests/loadimmutable_shadowing.yul @@ -0,0 +1,7 @@ +{ + function loadimmutable(a) {} +} +// ==== +// dialect: evm +// ---- +// ParserError 5568: (15-28): Cannot use builtin function name "loadimmutable" as identifier name. diff --git a/test/libyul/yulSyntaxTests/setimmutable_shadowing.yul b/test/libyul/yulSyntaxTests/setimmutable_shadowing.yul new file mode 100644 index 000000000..b76a5de9b --- /dev/null +++ b/test/libyul/yulSyntaxTests/setimmutable_shadowing.yul @@ -0,0 +1,7 @@ +{ + function setimmutable(a, b) {} +} +// ==== +// dialect: evm +// ---- +// ParserError 5568: (15-27): Cannot use builtin function name "setimmutable" as identifier name.