diff --git a/scripts/error_codes.py b/scripts/error_codes.py index d696ff8cc..8d919e41b 100755 --- a/scripts/error_codes.py +++ b/scripts/error_codes.py @@ -193,6 +193,7 @@ def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False): white_ids = { "9804", # Tested in test/libyul/ObjectParser.cpp. "1544", + "1749", "2674", "6367", "8387", diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index 932036b88..0a16aaccb 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -848,6 +848,84 @@ BOOST_AUTO_TEST_CASE(astid_reset) BOOST_CHECK(debugDataOf(result->statements.at(1))->astID == nullopt); } +BOOST_AUTO_TEST_CASE(astid_multi) +{ + ErrorList errorList; + ErrorReporter reporter(errorList); + auto const sourceText = R"( + /// @src -1:-1:-1 @ast-id 7 @src 1:1:1 @ast-id 8 + {} + )"; + EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{}); + shared_ptr result = parse(sourceText, dialect, reporter); + BOOST_REQUIRE(!!result); + BOOST_CHECK(result->debugData->astID == int64_t(8)); +} + +BOOST_AUTO_TEST_CASE(astid_invalid) +{ + ErrorList errorList; + ErrorReporter reporter(errorList); + auto const sourceText = R"( + /// @src -1:-1:-1 @ast-id abc @src 1:1:1 + {} + )"; + EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{}); + shared_ptr result = parse(sourceText, dialect, reporter); + BOOST_REQUIRE(!!result); + BOOST_REQUIRE(errorList.size() == 1); + BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError); + BOOST_TEST(errorList[0]->errorId() == 1749_error); + CHECK_LOCATION(result->debugData->location, "", -1, -1); +} + +BOOST_AUTO_TEST_CASE(astid_too_large) +{ + ErrorList errorList; + ErrorReporter reporter(errorList); + auto const sourceText = R"( + /// @ast-id 9223372036854775808 + {} + )"; + EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{}); + shared_ptr result = parse(sourceText, dialect, reporter); + BOOST_REQUIRE(!!result); + BOOST_REQUIRE(errorList.size() == 1); + BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError); + BOOST_TEST(errorList[0]->errorId() == 1749_error); +} + +BOOST_AUTO_TEST_CASE(astid_way_too_large) +{ + ErrorList errorList; + ErrorReporter reporter(errorList); + auto const sourceText = R"( + /// @ast-id 999999999999999999999999999999999999999 + {} + )"; + EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{}); + shared_ptr result = parse(sourceText, dialect, reporter); + BOOST_REQUIRE(!!result); + BOOST_REQUIRE(errorList.size() == 1); + BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError); + BOOST_TEST(errorList[0]->errorId() == 1749_error); +} + +BOOST_AUTO_TEST_CASE(astid_not_fully_numeric) +{ + ErrorList errorList; + ErrorReporter reporter(errorList); + auto const sourceText = R"( + /// @ast-id 9x + {} + )"; + EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{}); + shared_ptr result = parse(sourceText, dialect, reporter); + BOOST_REQUIRE(!!result); + BOOST_REQUIRE(errorList.size() == 1); + BOOST_TEST(errorList[0]->type() == Error::Type::SyntaxError); + BOOST_TEST(errorList[0]->errorId() == 1749_error); +} BOOST_AUTO_TEST_CASE(customSourceLocations_multiple_src_tags_on_one_line) {