mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add errorRecovery boolean to StandardCompiler
This commit is contained in:
parent
5fd9264dcd
commit
1a7e09ab7a
@ -301,7 +301,7 @@ boost::optional<Json::Value> checkAuxiliaryInputKeys(Json::Value const& _input)
|
|||||||
|
|
||||||
boost::optional<Json::Value> checkSettingsKeys(Json::Value const& _input)
|
boost::optional<Json::Value> checkSettingsKeys(Json::Value const& _input)
|
||||||
{
|
{
|
||||||
static set<string> keys{"evmVersion", "libraries", "metadata", "optimizer", "outputSelection", "remappings"};
|
static set<string> keys{"parserErrorRecovery", "evmVersion", "libraries", "metadata", "optimizer", "outputSelection", "remappings"};
|
||||||
return checkKeys(_input, keys, "settings");
|
return checkKeys(_input, keys, "settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,6 +576,13 @@ boost::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompile
|
|||||||
if (auto result = checkSettingsKeys(settings))
|
if (auto result = checkSettingsKeys(settings))
|
||||||
return *result;
|
return *result;
|
||||||
|
|
||||||
|
if (settings.isMember("parserErrorRecovery"))
|
||||||
|
{
|
||||||
|
if (!settings["parserErrorRecovery"].isBool())
|
||||||
|
return formatFatalError("JSONError", "\"settings.parserErrorRecovery\" must be a Boolean.");
|
||||||
|
ret.parserErrorRecovery = settings["parserErrorRecovery"].asBool();
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.isMember("evmVersion"))
|
if (settings.isMember("evmVersion"))
|
||||||
{
|
{
|
||||||
if (!settings["evmVersion"].isString())
|
if (!settings["evmVersion"].isString())
|
||||||
@ -675,6 +682,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
|||||||
for (auto const& smtLib2Response: _inputsAndSettings.smtLib2Responses)
|
for (auto const& smtLib2Response: _inputsAndSettings.smtLib2Responses)
|
||||||
compilerStack.addSMTLib2Response(smtLib2Response.first, smtLib2Response.second);
|
compilerStack.addSMTLib2Response(smtLib2Response.first, smtLib2Response.second);
|
||||||
compilerStack.setEVMVersion(_inputsAndSettings.evmVersion);
|
compilerStack.setEVMVersion(_inputsAndSettings.evmVersion);
|
||||||
|
compilerStack.setParserErrorRecovery(_inputsAndSettings.parserErrorRecovery);
|
||||||
compilerStack.setRemappings(_inputsAndSettings.remappings);
|
compilerStack.setRemappings(_inputsAndSettings.remappings);
|
||||||
compilerStack.setOptimiserSettings(std::move(_inputsAndSettings.optimiserSettings));
|
compilerStack.setOptimiserSettings(std::move(_inputsAndSettings.optimiserSettings));
|
||||||
compilerStack.setLibraries(_inputsAndSettings.libraries);
|
compilerStack.setLibraries(_inputsAndSettings.libraries);
|
||||||
|
@ -60,6 +60,7 @@ private:
|
|||||||
{
|
{
|
||||||
std::string language;
|
std::string language;
|
||||||
Json::Value errors;
|
Json::Value errors;
|
||||||
|
bool parserErrorRecovery = false;
|
||||||
std::map<std::string, std::string> sources;
|
std::map<std::string, std::string> sources;
|
||||||
std::map<h256, std::string> smtLib2Responses;
|
std::map<h256, std::string> smtLib2Responses;
|
||||||
langutil::EVMVersion evmVersion;
|
langutil::EVMVersion evmVersion;
|
||||||
|
@ -209,7 +209,6 @@ BOOST_AUTO_TEST_CASE(unexpected_trailing_test)
|
|||||||
BOOST_CHECK(containsError(result, "JSONError", "* Line 10, Column 2\n Extra non-whitespace after JSON value.\n"));
|
BOOST_CHECK(containsError(result, "JSONError", "* Line 10, Column 2\n Extra non-whitespace after JSON value.\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(smoke_test)
|
BOOST_AUTO_TEST_CASE(smoke_test)
|
||||||
{
|
{
|
||||||
char const* input = R"(
|
char const* input = R"(
|
||||||
@ -226,6 +225,43 @@ BOOST_AUTO_TEST_CASE(smoke_test)
|
|||||||
BOOST_CHECK(containsAtMostWarnings(result));
|
BOOST_CHECK(containsAtMostWarnings(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(error_recovery_field)
|
||||||
|
{
|
||||||
|
auto input = R"(
|
||||||
|
{
|
||||||
|
"language": "Solidity",
|
||||||
|
"settings": {
|
||||||
|
"parserErrorRecovery": "1"
|
||||||
|
},
|
||||||
|
"sources": {
|
||||||
|
"empty": {
|
||||||
|
"content": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
Json::Value result = compile(input);
|
||||||
|
BOOST_CHECK(containsError(result, "JSONError", "\"settings.parserErrorRecovery\" must be a Boolean."));
|
||||||
|
|
||||||
|
input = R"(
|
||||||
|
{
|
||||||
|
"language": "Solidity",
|
||||||
|
"settings": {
|
||||||
|
"parserErrorRecovery": true
|
||||||
|
},
|
||||||
|
"sources": {
|
||||||
|
"empty": {
|
||||||
|
"content": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
result = compile(input);
|
||||||
|
BOOST_CHECK(containsAtMostWarnings(result));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(optimizer_enabled_not_boolean)
|
BOOST_AUTO_TEST_CASE(optimizer_enabled_not_boolean)
|
||||||
{
|
{
|
||||||
char const* input = R"(
|
char const* input = R"(
|
||||||
|
@ -52,7 +52,7 @@ int parseUnsignedInteger(string::iterator& _it, string::iterator _end)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion _evmVersion, bool _errorRecovery): m_evmVersion(_evmVersion)
|
SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion _evmVersion, bool _parserErrorRecovery): m_evmVersion(_evmVersion)
|
||||||
{
|
{
|
||||||
ifstream file(_filename);
|
ifstream file(_filename);
|
||||||
if (!file)
|
if (!file)
|
||||||
@ -67,7 +67,7 @@ SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion _evmVersion
|
|||||||
m_settings.erase("optimize-yul");
|
m_settings.erase("optimize-yul");
|
||||||
}
|
}
|
||||||
m_expectations = parseExpectations(file);
|
m_expectations = parseExpectations(file);
|
||||||
m_errorRecovery = _errorRecovery;
|
m_parserErrorRecovery = _parserErrorRecovery;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCase::TestResult SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
|
TestCase::TestResult SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
|
||||||
@ -76,7 +76,7 @@ TestCase::TestResult SyntaxTest::run(ostream& _stream, string const& _linePrefix
|
|||||||
compiler().reset();
|
compiler().reset();
|
||||||
compiler().setSources({{"", versionPragma + m_source}});
|
compiler().setSources({{"", versionPragma + m_source}});
|
||||||
compiler().setEVMVersion(m_evmVersion);
|
compiler().setEVMVersion(m_evmVersion);
|
||||||
compiler().setParserErrorRecovery(m_errorRecovery);
|
compiler().setParserErrorRecovery(m_parserErrorRecovery);
|
||||||
compiler().setOptimiserSettings(
|
compiler().setOptimiserSettings(
|
||||||
m_optimiseYul ?
|
m_optimiseYul ?
|
||||||
OptimiserSettings::full() :
|
OptimiserSettings::full() :
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
{
|
{
|
||||||
return std::make_unique<SyntaxTest>(_config.filename, _config.evmVersion, true);
|
return std::make_unique<SyntaxTest>(_config.filename, _config.evmVersion, true);
|
||||||
}
|
}
|
||||||
SyntaxTest(std::string const& _filename, langutil::EVMVersion _evmVersion, bool _errorRecovery = false);
|
SyntaxTest(std::string const& _filename, langutil::EVMVersion _evmVersion, bool _parserErrorRecovery = false);
|
||||||
|
|
||||||
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
|
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ protected:
|
|||||||
std::vector<SyntaxTestError> m_errorList;
|
std::vector<SyntaxTestError> m_errorList;
|
||||||
bool m_optimiseYul = false;
|
bool m_optimiseYul = false;
|
||||||
langutil::EVMVersion const m_evmVersion;
|
langutil::EVMVersion const m_evmVersion;
|
||||||
bool m_errorRecovery = false;
|
bool m_parserErrorRecovery = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user