mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added error codes to SyntaxTest expectations (changed code)
This commit is contained in:
parent
e04cedafc5
commit
1d2ae7d82a
@ -64,7 +64,11 @@ struct InvalidAstError: virtual util::Exception {};
|
|||||||
* To create a new ID, one can add 0000_error and then run "python ./scripts/fix_error_ids.py"
|
* To create a new ID, one can add 0000_error and then run "python ./scripts/fix_error_ids.py"
|
||||||
* from the root of the repo.
|
* from the root of the repo.
|
||||||
*/
|
*/
|
||||||
struct ErrorId { unsigned long long error = 0; };
|
struct ErrorId
|
||||||
|
{
|
||||||
|
unsigned long long error = 0;
|
||||||
|
bool operator==(ErrorId const& _rhs) const { return error == _rhs.error; }
|
||||||
|
};
|
||||||
constexpr ErrorId operator"" _error(unsigned long long _error) { return ErrorId{ _error }; }
|
constexpr ErrorId operator"" _error(unsigned long long _error) { return ErrorId{ _error }; }
|
||||||
|
|
||||||
class Error: virtual public util::Exception
|
class Error: virtual public util::Exception
|
||||||
|
@ -165,8 +165,10 @@ void CommonSyntaxTest::printErrorList(
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED});
|
AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED});
|
||||||
_stream << _linePrefix;
|
_stream << _linePrefix << error.type;
|
||||||
_stream << error.type << ": ";
|
if (error.errorId.has_value())
|
||||||
|
_stream << ' ' << error.errorId->error;
|
||||||
|
_stream << ": ";
|
||||||
}
|
}
|
||||||
if (!error.sourceName.empty() || error.locationStart >= 0 || error.locationEnd >= 0)
|
if (!error.sourceName.empty() || error.locationStart >= 0 || error.locationEnd >= 0)
|
||||||
{
|
{
|
||||||
@ -206,13 +208,17 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
|
|||||||
if (it == line.end()) continue;
|
if (it == line.end()) continue;
|
||||||
|
|
||||||
auto typeBegin = it;
|
auto typeBegin = it;
|
||||||
while (it != line.end() && *it != ':')
|
while (it != line.end() && isalpha(*it))
|
||||||
++it;
|
++it;
|
||||||
string errorType(typeBegin, it);
|
string errorType(typeBegin, it);
|
||||||
|
|
||||||
// skip colon
|
skipWhitespace(it, line.end());
|
||||||
if (it != line.end()) it++;
|
|
||||||
|
|
||||||
|
optional<ErrorId> errorId;
|
||||||
|
if (it != line.end() && isdigit(*it))
|
||||||
|
errorId = ErrorId{static_cast<unsigned long long>(parseUnsignedInteger(it, line.end()))};
|
||||||
|
|
||||||
|
expect(it, line.end(), ':');
|
||||||
skipWhitespace(it, line.end());
|
skipWhitespace(it, line.end());
|
||||||
|
|
||||||
int locationStart = -1;
|
int locationStart = -1;
|
||||||
@ -242,6 +248,7 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
|
|||||||
string errorMessage(it, line.end());
|
string errorMessage(it, line.end());
|
||||||
expectations.emplace_back(SyntaxTestError{
|
expectations.emplace_back(SyntaxTestError{
|
||||||
move(errorType),
|
move(errorType),
|
||||||
|
move(errorId),
|
||||||
move(errorMessage),
|
move(errorMessage),
|
||||||
move(sourceName),
|
move(sourceName),
|
||||||
locationStart,
|
locationStart,
|
||||||
|
@ -33,6 +33,7 @@ namespace solidity::test
|
|||||||
struct SyntaxTestError
|
struct SyntaxTestError
|
||||||
{
|
{
|
||||||
std::string type;
|
std::string type;
|
||||||
|
std::optional<langutil::ErrorId> errorId;
|
||||||
std::string message;
|
std::string message;
|
||||||
std::string sourceName;
|
std::string sourceName;
|
||||||
int locationStart = -1;
|
int locationStart = -1;
|
||||||
@ -40,6 +41,7 @@ struct SyntaxTestError
|
|||||||
bool operator==(SyntaxTestError const& _rhs) const
|
bool operator==(SyntaxTestError const& _rhs) const
|
||||||
{
|
{
|
||||||
return type == _rhs.type &&
|
return type == _rhs.type &&
|
||||||
|
errorId == _rhs.errorId &&
|
||||||
message == _rhs.message &&
|
message == _rhs.message &&
|
||||||
sourceName == _rhs.sourceName &&
|
sourceName == _rhs.sourceName &&
|
||||||
locationStart == _rhs.locationStart &&
|
locationStart == _rhs.locationStart &&
|
||||||
|
@ -127,6 +127,7 @@ TestCase::TestResult SMTCheckerJSONTest::run(ostream& _stream, string const& _li
|
|||||||
end -= preamble.size();
|
end -= preamble.size();
|
||||||
m_errorList.emplace_back(SyntaxTestError{
|
m_errorList.emplace_back(SyntaxTestError{
|
||||||
error["type"].asString(),
|
error["type"].asString(),
|
||||||
|
error["errorId"].isNull() ? nullopt : optional<langutil::ErrorId>(langutil::ErrorId{error["errorId"].asUInt()}),
|
||||||
error["message"].asString(),
|
error["message"].asString(),
|
||||||
sourceName,
|
sourceName,
|
||||||
static_cast<int>(start),
|
static_cast<int>(start),
|
||||||
|
@ -79,6 +79,7 @@ void SyntaxTest::parseAndAnalyze()
|
|||||||
{
|
{
|
||||||
m_errorList.emplace_back(SyntaxTestError{
|
m_errorList.emplace_back(SyntaxTestError{
|
||||||
"UnimplementedFeatureError",
|
"UnimplementedFeatureError",
|
||||||
|
nullopt,
|
||||||
errorMessage(_e),
|
errorMessage(_e),
|
||||||
"",
|
"",
|
||||||
-1,
|
-1,
|
||||||
@ -106,6 +107,7 @@ void SyntaxTest::filterObtainedErrors()
|
|||||||
}
|
}
|
||||||
m_errorList.emplace_back(SyntaxTestError{
|
m_errorList.emplace_back(SyntaxTestError{
|
||||||
currentError->typeName(),
|
currentError->typeName(),
|
||||||
|
currentError->errorId(),
|
||||||
errorMessage(*currentError),
|
errorMessage(*currentError),
|
||||||
sourceName,
|
sourceName,
|
||||||
locationStart,
|
locationStart,
|
||||||
|
@ -66,6 +66,7 @@ void SyntaxTest::parseAndAnalyze()
|
|||||||
|
|
||||||
m_errorList.emplace_back(SyntaxTestError{
|
m_errorList.emplace_back(SyntaxTestError{
|
||||||
error->typeName(),
|
error->typeName(),
|
||||||
|
error->errorId(),
|
||||||
errorMessage(*error),
|
errorMessage(*error),
|
||||||
name,
|
name,
|
||||||
locationStart,
|
locationStart,
|
||||||
|
Loading…
Reference in New Issue
Block a user