Merge pull request #10235 from ethereum/onlyFailOnUnimplemented

Fail on assertion failures in yul code generation.
This commit is contained in:
Alex Beregszaszi 2021-01-14 16:55:07 +00:00 committed by GitHub
commit d4627d53eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 120 additions and 130 deletions

View File

@ -104,6 +104,7 @@ struct ErrorId
{
unsigned long long error = 0;
bool operator==(ErrorId const& _rhs) const { return error == _rhs.error; }
bool operator!=(ErrorId const& _rhs) const { return !(*this == _rhs); }
};
constexpr ErrorId operator"" _error(unsigned long long _error) { return ErrorId{ _error }; }

View File

@ -30,6 +30,7 @@
using namespace std;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::langutil;
using namespace solidity::util;
using namespace solidity::util::formatting;
using namespace solidity::frontend::test;
@ -119,8 +120,6 @@ TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePref
}
TestCase::TestResult SemanticTest::runTest(ostream& _stream, string const& _linePrefix, bool _formatted, bool _compileViaYul, bool _compileToEwasm)
{
try
{
bool success = true;
@ -151,6 +150,9 @@ TestCase::TestResult SemanticTest::runTest(ostream& _stream, string const& _line
bool constructed = false;
for (auto& test: m_tests)
{
try
{
if (constructed)
{
@ -175,6 +177,19 @@ TestCase::TestResult SemanticTest::runTest(ostream& _stream, string const& _line
soltestAssert(deploy("", 0, bytes(), libraries), "Failed to deploy contract.");
constructed = true;
}
}
catch (langutil::UnimplementedFeatureError const&)
{
// ignore unimplemented feature errors when forcibly trying to compile via yul.
if (!_compileViaYul || m_runWithYul)
throw;
}
catch (langutil::Error const& _error)
{
// ignore unimplemented feature errors when forcibly trying to compile via yul.
if (_error.errorId() != 1834_error || !_compileViaYul || m_runWithYul)
throw;
}
if (test.call().kind == FunctionCall::Kind::Storage)
{
@ -268,32 +283,6 @@ TestCase::TestResult SemanticTest::runTest(ostream& _stream, string const& _line
<< _linePrefix << "Note that the test also has to pass via Yul." << endl;
return TestResult::Failure;
}
}
catch (WhiskersError const&)
{
// this is an error in Whiskers template, so should be thrown anyway
throw;
}
catch (YulException const&)
{
// this should be an error in yul compilation or translation
throw;
}
catch (boost::exception const&)
{
if (!_compileViaYul || m_runWithYul)
throw;
}
catch (std::exception const&)
{
if (!_compileViaYul || m_runWithYul)
throw;
}
catch (...)
{
if (!_compileViaYul || m_runWithYul)
throw;
}
return TestResult::Success;
}