diff --git a/test/libyul/yulSyntaxTests/datacopy.yul b/test/libyul/yulSyntaxTests/datacopy.yul deleted file mode 100644 index 73d2bcd6d..000000000 --- a/test/libyul/yulSyntaxTests/datacopy.yul +++ /dev/null @@ -1,12 +0,0 @@ -{ - datacopy(0, 1, 2) - datasize("") - datasize(0) // This should not be valid. - dataoffset("") - dataoffset(0) // This should not be valid. -} -// ---- -// TypeError 3517: (37-39): Unknown data object "". -// TypeError 5859: (54-55): Function expects string literal. -// TypeError 3517: (101-103): Unknown data object "". -// TypeError 5859: (120-121): Function expects string literal. diff --git a/test/libyul/yulSyntaxTests/objects/basic_subobject.yul b/test/libyul/yulSyntaxTests/objects/basic_subobject.yul new file mode 100644 index 000000000..031198868 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/basic_subobject.yul @@ -0,0 +1,7 @@ +object "A" { + code {} + + object "B" { + code {} + } +} diff --git a/test/libyul/yulSyntaxTests/objects/code.yul b/test/libyul/yulSyntaxTests/objects/code.yul new file mode 100644 index 000000000..89caa8e50 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/code.yul @@ -0,0 +1,18 @@ +object "A" { + code { + function f() -> offset, len { + offset := dataoffset("A") + len := datasize("A") + } + + let offset, len := f() + codecopy(0, offset, len) + } + + data "hello" "hello world text" + object "hello" { + code {} + } +} +// ---- +// ParserError 8794: (226-233): Object name "hello" already exists inside the containing object. diff --git a/test/libyul/yulSyntaxTests/objects/code_without_object.yul b/test/libyul/yulSyntaxTests/objects/code_without_object.yul new file mode 100644 index 000000000..e67c5c36d --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/code_without_object.yul @@ -0,0 +1,4 @@ +code { +} +// ---- +// ParserError 4294: (0-4): Expected keyword "object". diff --git a/test/libyul/yulSyntaxTests/objects/complex_subobject.yul b/test/libyul/yulSyntaxTests/objects/complex_subobject.yul new file mode 100644 index 000000000..de48bc549 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/complex_subobject.yul @@ -0,0 +1,35 @@ +object "A" { + code {} + data "1" hex"001122" + + object "B" { + code {} + data "2" "" + + object "B_C" { + code {} + + object "B_C_1" { + code {} + } + object "B_C_2" { + code {} + } + } + } + + object "C" { + code {} + } + + object "D" { + code {} + + object "D_1" { + code {} + } + object "D_2" { + code {} + } + } +} diff --git a/test/libyul/yulSyntaxTests/objects/conflict_data_data.yul b/test/libyul/yulSyntaxTests/objects/conflict_data_data.yul new file mode 100644 index 000000000..e09bd8b37 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/conflict_data_data.yul @@ -0,0 +1,8 @@ +object "A" { + code {} + + data "B" "" + data "B" hex"00" +} +// ---- +// ParserError 8794: (45-48): Object name "B" already exists inside the containing object. diff --git a/test/libyul/yulSyntaxTests/objects/conflict_data_parent.yul b/test/libyul/yulSyntaxTests/objects/conflict_data_parent.yul new file mode 100644 index 000000000..5edb1bd3a --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/conflict_data_parent.yul @@ -0,0 +1,9 @@ +object "A" { + code {} + + object "A" { + code {} + } +} +// ---- +// ParserError 8311: (33-36): Object name cannot be the same as the name of the containing object. diff --git a/test/libyul/yulSyntaxTests/objects/conflict_object_data.yul b/test/libyul/yulSyntaxTests/objects/conflict_object_data.yul new file mode 100644 index 000000000..fd64093ad --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/conflict_object_data.yul @@ -0,0 +1,10 @@ +object "A" { + code {} + + data "B" "" + object "B" { + code {} + } +} +// ---- +// ParserError 8794: (47-50): Object name "B" already exists inside the containing object. diff --git a/test/libyul/yulSyntaxTests/objects/conflict_object_object.yul b/test/libyul/yulSyntaxTests/objects/conflict_object_object.yul new file mode 100644 index 000000000..1b83be4f7 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/conflict_object_object.yul @@ -0,0 +1,12 @@ +object "A" { + code {} + + object "B" { + code {} + } + object "B" { + code {} + } +} +// ---- +// ParserError 8794: (64-67): Object name "B" already exists inside the containing object. diff --git a/test/libyul/yulSyntaxTests/objects/conflict_object_parent.yul b/test/libyul/yulSyntaxTests/objects/conflict_object_parent.yul new file mode 100644 index 000000000..44a3d3a2d --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/conflict_object_parent.yul @@ -0,0 +1,7 @@ +object "A" { + code {} + + data "A" "" +} +// ---- +// ParserError 8311: (31-34): Object name cannot be the same as the name of the containing object. diff --git a/test/libyul/yulSyntaxTests/objects/data.yul b/test/libyul/yulSyntaxTests/objects/data.yul new file mode 100644 index 000000000..47d7b59c7 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/data.yul @@ -0,0 +1,9 @@ +object "A" { + code { + datacopy(0, dataoffset("3"), datasize("3")) + } + data "1" "" + data "2" hex"0011" + data "3" "hello world this is longer than 32 bytes and should still work" +} +// ---- diff --git a/test/libyul/yulSyntaxTests/objects/data_access.yul b/test/libyul/yulSyntaxTests/objects/data_access.yul new file mode 100644 index 000000000..e9455fafa --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/data_access.yul @@ -0,0 +1,9 @@ +object "A" { + code { + pop(dataoffset("B")) + pop(datasize("B")) + } + + data "B" hex"00" +} +// ---- diff --git a/test/libyul/yulSyntaxTests/objects/data_first.yul b/test/libyul/yulSyntaxTests/objects/data_first.yul new file mode 100644 index 000000000..018674765 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/data_first.yul @@ -0,0 +1,6 @@ +object "A" { + data "B" "" + code {} +} +// ---- +// ParserError 4846: (15-19): Expected keyword "code". diff --git a/test/libyul/yulSyntaxTests/objects/data_hex_name.yul b/test/libyul/yulSyntaxTests/objects/data_hex_name.yul new file mode 100644 index 000000000..28f7282d7 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/data_hex_name.yul @@ -0,0 +1,6 @@ +object "A" { + code {} + data hex"11" "" +} +// ---- +// ParserError 2314: (30-37): Expected 'StringLiteral' but got 'HexStringLiteral' diff --git a/test/libyul/yulSyntaxTests/objects/data_invalid_hex1.yul b/test/libyul/yulSyntaxTests/objects/data_invalid_hex1.yul new file mode 100644 index 000000000..c80f82c20 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/data_invalid_hex1.yul @@ -0,0 +1,8 @@ +object "A" { + code { + } + data "1" hex"0" + data "1" hex"wronghexencoding" +} +// ---- +// ParserError 2314: (37-41): Expected 'StringLiteral' but got 'ILLEGAL' diff --git a/test/libyul/yulSyntaxTests/objects/data_invalid_hex2.yul b/test/libyul/yulSyntaxTests/objects/data_invalid_hex2.yul new file mode 100644 index 000000000..17029e4f7 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/data_invalid_hex2.yul @@ -0,0 +1,8 @@ +object "A" { + code { + } + data "1" hex"wronghexencoding" + data "2" hex"0" +} +// ---- +// ParserError 2314: (37-41): Expected 'StringLiteral' but got 'ILLEGAL' diff --git a/test/libyul/yulSyntaxTests/objects/datacopy.yul b/test/libyul/yulSyntaxTests/objects/datacopy.yul new file mode 100644 index 000000000..bc7e211d8 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/datacopy.yul @@ -0,0 +1,8 @@ +{ + datacopy(0, 1, 2) + + // datacopy also accepts pretty much anything which can be turned into a number + let x := 0 + let s := "" + datacopy(x, "11", s) +} diff --git a/test/libyul/yulSyntaxTests/objects/dataoffset_nonliteral.yul b/test/libyul/yulSyntaxTests/objects/dataoffset_nonliteral.yul new file mode 100644 index 000000000..d53e26281 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/dataoffset_nonliteral.yul @@ -0,0 +1,10 @@ +object "A" { + code { + let x := "B" + pop(dataoffset(x)) + } + + data "B" hex"00" +} +// ---- +// TypeError 9114: (47-57): Function expects direct literals as arguments. diff --git a/test/libyul/yulSyntaxTests/objects/dataoffset_nonstring.yul b/test/libyul/yulSyntaxTests/objects/dataoffset_nonstring.yul new file mode 100644 index 000000000..93a981d92 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/dataoffset_nonstring.yul @@ -0,0 +1,7 @@ +object "A" { + code { + pop(dataoffset(0)) + } +} +// ---- +// TypeError 5859: (41-42): Function expects string literal. diff --git a/test/libyul/yulSyntaxTests/objects/dataoffset_notfound.yul b/test/libyul/yulSyntaxTests/objects/dataoffset_notfound.yul new file mode 100644 index 000000000..14df40201 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/dataoffset_notfound.yul @@ -0,0 +1,8 @@ +object "A" { + code { + pop(dataoffset("C")) + } + data "B" "" +} +// ---- +// TypeError 3517: (41-44): Unknown data object "C". diff --git a/test/libyul/yulSyntaxTests/objects/datasize_nonliteral.yul b/test/libyul/yulSyntaxTests/objects/datasize_nonliteral.yul new file mode 100644 index 000000000..837408b9a --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/datasize_nonliteral.yul @@ -0,0 +1,10 @@ +object "A" { + code { + let x := "B" + pop(datasize(x)) + } + + data "B" hex"00" +} +// ---- +// TypeError 9114: (47-55): Function expects direct literals as arguments. diff --git a/test/libyul/yulSyntaxTests/objects/datasize_nonstring.yul b/test/libyul/yulSyntaxTests/objects/datasize_nonstring.yul new file mode 100644 index 000000000..19042a2df --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/datasize_nonstring.yul @@ -0,0 +1,7 @@ +object "A" { + code { + pop(datasize(0)) + } +} +// ---- +// TypeError 5859: (39-40): Function expects string literal. diff --git a/test/libyul/yulSyntaxTests/objects/datasize_notfound.yul b/test/libyul/yulSyntaxTests/objects/datasize_notfound.yul new file mode 100644 index 000000000..48a2c268e --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/datasize_notfound.yul @@ -0,0 +1,8 @@ +object "A" { + code { + pop(datasize("C")) + } + data "B" "" +} +// ---- +// TypeError 3517: (39-42): Unknown data object "C". diff --git a/test/libyul/yulSyntaxTests/objects/empty_code.yul b/test/libyul/yulSyntaxTests/objects/empty_code.yul new file mode 100644 index 000000000..a32efaaff --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/empty_code.yul @@ -0,0 +1,3 @@ +object "A" { + code { } +} diff --git a/test/libyul/yulSyntaxTests/objects/empty_data.yul b/test/libyul/yulSyntaxTests/objects/empty_data.yul new file mode 100644 index 000000000..b2456a7ae --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/empty_data.yul @@ -0,0 +1,5 @@ +object "A" { + data "tmp" "" +} +// ---- +// ParserError 4846: (15-19): Expected keyword "code". diff --git a/test/libyul/yulSyntaxTests/objects/empty_object.yul b/test/libyul/yulSyntaxTests/objects/empty_object.yul new file mode 100644 index 000000000..cc9019e55 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/empty_object.yul @@ -0,0 +1,4 @@ +object "A" { +} +// ---- +// ParserError 4846: (13-14): Expected keyword "code". diff --git a/test/libyul/yulSyntaxTests/objects/empty_object_name.yul b/test/libyul/yulSyntaxTests/objects/empty_object_name.yul new file mode 100644 index 000000000..653bf4a0f --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/empty_object_name.yul @@ -0,0 +1,5 @@ +object "" { +} +// ---- +// ParserError 3287: (7-9): Object name cannot be empty. +// ParserError 4846: (12-13): Expected keyword "code". diff --git a/test/libyul/yulSyntaxTests/objects/incomplete1.yul b/test/libyul/yulSyntaxTests/objects/incomplete1.yul new file mode 100644 index 000000000..6698f45a2 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/incomplete1.yul @@ -0,0 +1,3 @@ +object { +// ---- +// ParserError 2314: (7-8): Expected 'StringLiteral' but got '{' diff --git a/test/libyul/yulSyntaxTests/objects/incomplete2.yul b/test/libyul/yulSyntaxTests/objects/incomplete2.yul new file mode 100644 index 000000000..f421074f5 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/incomplete2.yul @@ -0,0 +1,7 @@ +object "A" { + code {} +} + +object +// ---- +// ParserError 2314: (26-32): Expected end of source but got identifier diff --git a/test/libyul/yulSyntaxTests/objects/multiple_code.yul b/test/libyul/yulSyntaxTests/objects/multiple_code.yul new file mode 100644 index 000000000..fd3347600 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/multiple_code.yul @@ -0,0 +1,6 @@ +object "A" { + code { } + code { } +} +// ---- +// ParserError 8143: (26-30): Expected keyword "data" or "object" or "}". diff --git a/test/libyul/yulSyntaxTests/objects/multiple_data.yul b/test/libyul/yulSyntaxTests/objects/multiple_data.yul new file mode 100644 index 000000000..5a48edd91 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/multiple_data.yul @@ -0,0 +1,6 @@ +object "A" { + code { } + data "one" "" + data "two" "" +} +// ---- diff --git a/test/libyul/yulSyntaxTests/objects/multiple_root_object.yul b/test/libyul/yulSyntaxTests/objects/multiple_root_object.yul new file mode 100644 index 000000000..842cfcfb5 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/multiple_root_object.yul @@ -0,0 +1,8 @@ +object "A" { + code { } +} +object "B" { + code { } +} +// ---- +// ParserError 2314: (26-32): Expected end of source but got identifier diff --git a/test/libyul/yulSyntaxTests/objects/nested_object.yul b/test/libyul/yulSyntaxTests/objects/nested_object.yul new file mode 100644 index 000000000..426cc5586 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/nested_object.yul @@ -0,0 +1,10 @@ +object "outer" { + code { let x := mload(0) } + data "x" "stringdata" + object "inner" { + code { mstore(0, 1) } + object "inner inner" { code {} } + data "innerx" "abc" + data "innery" "def" + } +} diff --git a/test/libyul/yulSyntaxTests/objects/object_hex_name.yul b/test/libyul/yulSyntaxTests/objects/object_hex_name.yul new file mode 100644 index 000000000..c58b5fd19 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/object_hex_name.yul @@ -0,0 +1,5 @@ +object hex"11" { + code {} +} +// ---- +// ParserError 2314: (7-14): Expected 'StringLiteral' but got 'HexStringLiteral' diff --git a/test/libyul/yulSyntaxTests/objects/subobject_access.yul b/test/libyul/yulSyntaxTests/objects/subobject_access.yul new file mode 100644 index 000000000..59426a0aa --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/subobject_access.yul @@ -0,0 +1,11 @@ +object "A" { + code { + pop(dataoffset("B")) + pop(datasize("B")) + } + + object "B" { + code {} + } +} +// ---- diff --git a/test/libyul/yulSyntaxTests/objects/subobject_first.yul b/test/libyul/yulSyntaxTests/objects/subobject_first.yul new file mode 100644 index 000000000..369e7180e --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/subobject_first.yul @@ -0,0 +1,9 @@ +object "A" { + object "B" { + code {} + } + + code {} +} +// ---- +// ParserError 4846: (15-21): Expected keyword "code". diff --git a/test/libyul/yulSyntaxTests/objects/subobject_hex_name.yul b/test/libyul/yulSyntaxTests/objects/subobject_hex_name.yul new file mode 100644 index 000000000..af0581067 --- /dev/null +++ b/test/libyul/yulSyntaxTests/objects/subobject_hex_name.yul @@ -0,0 +1,8 @@ +object "A" { + code {} + object hex"11" { + code {} + } +} +// ---- +// ParserError 2314: (32-39): Expected 'StringLiteral' but got 'HexStringLiteral'