From 02d1f8c41aa4d9d36a002d12f3ced24ac21bdb85 Mon Sep 17 00:00:00 2001 From: a3d4 Date: Tue, 12 May 2020 18:13:17 +0200 Subject: [PATCH] Remove a dedicated error flag from DeclarationTypeChecker --- liblangutil/ErrorReporter.h | 6 ++++++ libsolidity/analysis/DeclarationTypeChecker.cpp | 6 ++---- libsolidity/analysis/DeclarationTypeChecker.h | 1 - .../nameAndTypeResolution/105_constant_input_parameter.sol | 2 -- .../syntaxTests/parsing/location_specifiers_for_params.sol | 2 -- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/liblangutil/ErrorReporter.h b/liblangutil/ErrorReporter.h index 466bb66cb..a52e978af 100644 --- a/liblangutil/ErrorReporter.h +++ b/liblangutil/ErrorReporter.h @@ -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; diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index 4e55151e9..a06679b97 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -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; } diff --git a/libsolidity/analysis/DeclarationTypeChecker.h b/libsolidity/analysis/DeclarationTypeChecker.h index b704c4fd2..e54075998 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.h +++ b/libsolidity/analysis/DeclarationTypeChecker.h @@ -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; diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol index ba05fcb31..aab8a183a 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol index bf78e59c6..b9b1f97cd 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol @@ -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.