Merge pull request #8915 from a3d4/partfix-5819-remove-erroroccurred-flag

Remove a dedicated error flag from DeclarationTypeChecker and other classes
This commit is contained in:
chriseth 2020-05-12 20:18:33 +02:00 committed by GitHub
commit b2122d479f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 9 deletions

View File

@ -134,6 +134,12 @@ public:
return m_errorCount > 0;
}
/// @returns the number of errors (ignores warnings).
unsigned errorCount() const
{
return m_errorCount;
}
// @returns true if the maximum error count has been reached.
bool hasExcessiveErrors() const;

View File

@ -361,24 +361,22 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
void DeclarationTypeChecker::typeError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.typeError(2311_error, _location, _description);
}
void DeclarationTypeChecker::fatalTypeError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.fatalTypeError(5651_error, _location, _description);
}
void DeclarationTypeChecker::fatalDeclarationError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.fatalDeclarationError(2046_error, _location, _description);
}
bool DeclarationTypeChecker::check(ASTNode const& _node)
{
unsigned errorCount = m_errorReporter.errorCount();
_node.accept(*this);
return !m_errorOccurred;
return m_errorReporter.errorCount() == errorCount;
}

View File

@ -69,7 +69,6 @@ private:
void fatalDeclarationError(langutil::SourceLocation const& _location, std::string const& _description);
langutil::ErrorReporter& m_errorReporter;
bool m_errorOccurred = false;
langutil::EVMVersion m_evmVersion;
bool m_insideFunctionType = false;
bool m_recursiveStructSeen = false;

View File

@ -3,5 +3,3 @@ contract test {
}
// ----
// DeclarationError: (31-55): The "constant" keyword can only be used for state variables.
// TypeError: (31-55): Constants of non-value type not yet implemented.
// TypeError: (31-55): Uninitialized "constant" variable.

View File

@ -3,5 +3,3 @@ contract Foo {
}
// ----
// DeclarationError: (30-55): The "constant" keyword can only be used for state variables.
// TypeError: (30-55): Constants of non-value type not yet implemented.
// TypeError: (30-55): Uninitialized "constant" variable.