Emit warning when using the Yul optimiser

This commit is contained in:
Alex Beregszaszi 2019-03-25 13:56:12 +00:00 committed by chriseth
parent dce27bb452
commit 0432401e20
7 changed files with 48 additions and 0 deletions

View File

@ -179,6 +179,12 @@ bool CompilerStack::parse()
if (SemVerVersion{string(VersionString)}.isPrerelease())
m_errorReporter.warning("This is a pre-release compiler version, please do not use it in production.");
if (m_optimiserSettings.runYulOptimiser)
m_errorReporter.warning(
"The Yul optimiser is still experimental. "
"Do not use it in production unless correctness of generated code is verified with extensive tests."
);
vector<string> sourcesToParse;
for (auto const& s: m_sources)
sourcesToParse.push_back(s.first);

View File

@ -1,3 +1,4 @@
Warning: The Yul optimiser is still experimental. Do not use it in production unless correctness of generated code is verified with extensive tests.
gas_test_abiv2_optimize_yul/input.sol:2:1: Warning: Experimental features are turned on. Do not use experimental features on live deployments.
pragma experimental ABIEncoderV2;
^-------------------------------^

View File

@ -0,0 +1,17 @@
{
"language": "Solidity",
"sources":
{
"A":
{
"content": "pragma solidity >=0.0; contract C { function f() public pure {} }"
}
},
"settings":
{
"optimizer": {
"enabled": true,
"details": { "yul": true }
}
}
}

View File

@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"Warning: The Yul optimiser is still experimental. Do not use it in production unless correctness of generated code is verified with extensive tests.\n","message":"The Yul optimiser is still experimental. Do not use it in production unless correctness of generated code is verified with extensive tests.","severity":"warning","type":"Warning"}],"sources":{"A":{"id":0}}}

View File

@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources":
{
"A":
{
"content": "pragma solidity >=0.0; contract C { function f() public pure {} }"
}
},
"settings":
{
"optimizer": {
"details": { "yul": true, "yulDetails": {} }
}
}
}

View File

@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"Warning: The Yul optimiser is still experimental. Do not use it in production unless correctness of generated code is verified with extensive tests.\n","message":"The Yul optimiser is still experimental. Do not use it in production unless correctness of generated code is verified with extensive tests.","severity":"warning","type":"Warning"}],"sources":{"A":{"id":0}}}

View File

@ -996,6 +996,12 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_details_different)
)";
Json::Value result = compile(input);
BOOST_CHECK(containsAtMostWarnings(result));
BOOST_CHECK(containsError(
result,
"Warning",
"The Yul optimiser is still experimental. "
"Do not use it in production unless correctness of generated code is verified with extensive tests."
));
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["metadata"].isString());