Remove a dedicated error flag from DeclarationTypeChecker

This commit is contained in:
a3d4 2020-05-12 18:13:17 +02:00
parent b014b89edc
commit 02d1f8c41a
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.