diff --git a/test/cmdlineTests/standard_yul_object_invalid_sub/output.json b/test/cmdlineTests/standard_yul_object_invalid_sub/output.json index 5008d4916..a8f78b985 100644 --- a/test/cmdlineTests/standard_yul_object_invalid_sub/output.json +++ b/test/cmdlineTests/standard_yul_object_invalid_sub/output.json @@ -1,4 +1,4 @@ -{"errors":[{"component":"general","formattedMessage":"A:1:40: TypeError: Unknown data object \"NamedObject.\". +{"errors":[{"component":"general","formattedMessage":"A:1:51: TypeError: Unknown data object \"NamedObject.\". object \"NamedObject\" { code { let x := dataoffset(\"NamedObject.\") sstore(add(x, 0), 0) } object \"OtherObject\" { code { revert(0, 0) } } } - ^--------^ -","message":"Unknown data object \"NamedObject.\".","severity":"error","sourceLocation":{"end":49,"file":"A","start":39},"type":"TypeError"}]} + ^------------^ +","message":"Unknown data object \"NamedObject.\".","severity":"error","sourceLocation":{"end":64,"file":"A","start":50},"type":"TypeError"}]} diff --git a/test/libyul/ObjectParser.cpp b/test/libyul/ObjectParser.cpp index 2d932006e..2d7034897 100644 --- a/test/libyul/ObjectParser.cpp +++ b/test/libyul/ObjectParser.cpp @@ -258,6 +258,16 @@ BOOST_AUTO_TEST_CASE(arg_to_dataoffset_must_be_literal) CHECK_ERROR(code, TypeError, "Function expects direct literals as arguments."); } +BOOST_AUTO_TEST_CASE(arg_to_dataoffset_must_be_string_literal) +{ + string code = R"( + object "outer" { + code { let y := dataoffset(0) } + } + )"; + CHECK_ERROR(code, TypeError, "Function expects string literal."); +} + BOOST_AUTO_TEST_CASE(arg_to_datasize_must_be_literal) { string code = R"( @@ -268,6 +278,16 @@ BOOST_AUTO_TEST_CASE(arg_to_datasize_must_be_literal) CHECK_ERROR(code, TypeError, "Function expects direct literals as arguments."); } +BOOST_AUTO_TEST_CASE(arg_to_datasize_must_be_string_literal) +{ + string code = R"( + object "outer" { + code { let y := datasize(0) } + } + )"; + CHECK_ERROR(code, TypeError, "Function expects string literal."); +} + BOOST_AUTO_TEST_CASE(args_to_datacopy_are_arbitrary) { string code = R"( diff --git a/test/libyul/yulSyntaxTests/datacopy.yul b/test/libyul/yulSyntaxTests/datacopy.yul new file mode 100644 index 000000000..73d2bcd6d --- /dev/null +++ b/test/libyul/yulSyntaxTests/datacopy.yul @@ -0,0 +1,12 @@ +{ + 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/linkersymbol_bad_literal.yul b/test/libyul/yulSyntaxTests/linkersymbol_bad_literal.yul new file mode 100644 index 000000000..15ac5dccb --- /dev/null +++ b/test/libyul/yulSyntaxTests/linkersymbol_bad_literal.yul @@ -0,0 +1,11 @@ +{ + pop(linkersymbol(0)) + pop(linkersymbol(true)) + pop(linkersymbol(false)) +} +// ==== +// dialect: evm +// ---- +// TypeError 5859: (23-24): Function expects string literal. +// TypeError 5859: (48-52): Function expects string literal. +// TypeError 5859: (76-81): Function expects string literal. diff --git a/test/libyul/yulSyntaxTests/loadimmutable_bad_literal.yul b/test/libyul/yulSyntaxTests/loadimmutable_bad_literal.yul new file mode 100644 index 000000000..2aadd2f20 --- /dev/null +++ b/test/libyul/yulSyntaxTests/loadimmutable_bad_literal.yul @@ -0,0 +1,11 @@ +{ + pop(loadimmutable(0)) + pop(loadimmutable(true)) + pop(loadimmutable(false)) +} +// ==== +// dialect: evm +// ---- +// TypeError 5859: (24-25): Function expects string literal. +// TypeError 5859: (50-54): Function expects string literal. +// TypeError 5859: (79-84): Function expects string literal. diff --git a/test/libyul/yulSyntaxTests/setimmutable_bad_literal.yul b/test/libyul/yulSyntaxTests/setimmutable_bad_literal.yul new file mode 100644 index 000000000..6f19c6edb --- /dev/null +++ b/test/libyul/yulSyntaxTests/setimmutable_bad_literal.yul @@ -0,0 +1,11 @@ +{ + setimmutable(0, 0x1234567890123456789012345678901234567890) + setimmutable(true, 0x1234567890123456789012345678901234567890) + setimmutable(false, 0x1234567890123456789012345678901234567890) +} +// ==== +// dialect: evm +// ---- +// TypeError 5859: (19-20): Function expects string literal. +// TypeError 5859: (83-87): Function expects string literal. +// TypeError 5859: (150-155): Function expects string literal.