diff --git a/libsolidity/interface/Exceptions.cpp b/libsolidity/interface/Exceptions.cpp index 90a680b4d..f4ce8bc8b 100644 --- a/libsolidity/interface/Exceptions.cpp +++ b/libsolidity/interface/Exceptions.cpp @@ -56,3 +56,10 @@ Error::Error(Type _type): m_type(_type) break; } } + +bool Error::searchForSubstring(const std::string& _substr) const +{ + if (const std::string* str = boost::get_error_info(*this)) + return str->find(_substr) != std::string::npos; + return _substr.empty(); +} diff --git a/libsolidity/interface/Exceptions.h b/libsolidity/interface/Exceptions.h index 78eb88aa9..a97699444 100644 --- a/libsolidity/interface/Exceptions.h +++ b/libsolidity/interface/Exceptions.h @@ -23,7 +23,6 @@ #pragma once #include -#include #include #include #include @@ -58,13 +57,7 @@ public: Type type() const { return m_type; } std::string const& typeName() const { return m_typeName; } - bool regex_search(const std::string& _reg) const - { - if (std::string const* str = boost::get_error_info(*this)) - return std::regex_search(*str, std::regex(_reg)); - else - return false; - } + bool searchForSubstring(const std::string& _substr) const; /// helper functions static Error const* containsErrorOfType(ErrorList const& _list, Error::Type _type) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 57ee86d64..0022dfb22 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -165,7 +165,7 @@ do \ { \ Error err = expectError((text), (warning)); \ BOOST_CHECK(err.type() == (Error::Type::typ)); \ - BOOST_CHECK(err.regex_search({substring})); \ + BOOST_CHECK(err.searchForSubstring(substring)); \ } while(0) // [checkError(text, type, substring)] asserts that the compilation down to typechecking @@ -4104,7 +4104,7 @@ BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) auto sourceAndError = parseAnalyseAndReturnError(text, true, false); BOOST_REQUIRE(!!sourceAndError.second); BOOST_REQUIRE(!!sourceAndError.first); - BOOST_CHECK(sourceAndError.second->regex_search("Source file does not specify required compiler version!")); + BOOST_CHECK(sourceAndError.second->searchForSubstring("Source file does not specify required compiler version!")); } BOOST_AUTO_TEST_CASE(unsatisfied_version)