mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11983 from ethereum/fix-fatal-error-hiding-non-fatal-errors-in-standard-json
Don't discard non-fatal errors in Yul mode in Standard JSON when followed by a fatal error
This commit is contained in:
commit
c9f98f2cc2
@ -28,6 +28,7 @@ Bugfixes:
|
|||||||
* SMTChecker: Fix false positive in external calls from constructors.
|
* SMTChecker: Fix false positive in external calls from constructors.
|
||||||
* SMTChecker: Fix internal error on some multi-source uses of ``abi.*``, cryptographic functions and constants.
|
* SMTChecker: Fix internal error on some multi-source uses of ``abi.*``, cryptographic functions and constants.
|
||||||
* SMTChecker: Fix BMC's constraints regarding internal functions.
|
* SMTChecker: Fix BMC's constraints regarding internal functions.
|
||||||
|
* Standard JSON: Fix non-fatal errors in Yul mode being discarded if followed by a fatal error.
|
||||||
* Type Checker: Disallow modifier declarations and definitions in interfaces.
|
* Type Checker: Disallow modifier declarations and definitions in interfaces.
|
||||||
* Yul Optimizer: Fix a crash in LoadResolver, when ``keccak256`` has particular non-identifier arguments.
|
* Yul Optimizer: Fix a crash in LoadResolver, when ``keccak256`` has particular non-identifier arguments.
|
||||||
|
|
||||||
|
@ -1312,16 +1312,49 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
|||||||
|
|
||||||
Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
||||||
{
|
{
|
||||||
if (_inputsAndSettings.sources.size() != 1)
|
|
||||||
return formatFatalError("JSONError", "Yul mode only supports exactly one input file.");
|
|
||||||
if (!_inputsAndSettings.smtLib2Responses.empty())
|
|
||||||
return formatFatalError("JSONError", "Yul mode does not support smtlib2responses.");
|
|
||||||
if (!_inputsAndSettings.remappings.empty())
|
|
||||||
return formatFatalError("JSONError", "Field \"settings.remappings\" cannot be used for Yul.");
|
|
||||||
if (_inputsAndSettings.revertStrings != RevertStrings::Default)
|
|
||||||
return formatFatalError("JSONError", "Field \"settings.debug.revertStrings\" cannot be used for Yul.");
|
|
||||||
|
|
||||||
Json::Value output = Json::objectValue;
|
Json::Value output = Json::objectValue;
|
||||||
|
output["errors"] = std::move(_inputsAndSettings.errors);
|
||||||
|
|
||||||
|
if (_inputsAndSettings.sources.size() != 1)
|
||||||
|
{
|
||||||
|
output["errors"].append(formatError(
|
||||||
|
Error::Severity::Error,
|
||||||
|
"JSONError",
|
||||||
|
"general",
|
||||||
|
"Yul mode only supports exactly one input file."
|
||||||
|
));
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
if (!_inputsAndSettings.smtLib2Responses.empty())
|
||||||
|
{
|
||||||
|
output["errors"].append(formatError(
|
||||||
|
Error::Severity::Error,
|
||||||
|
"JSONError",
|
||||||
|
"general",
|
||||||
|
"Yul mode does not support smtlib2responses."
|
||||||
|
));
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
if (!_inputsAndSettings.remappings.empty())
|
||||||
|
{
|
||||||
|
output["errors"].append(formatError(
|
||||||
|
Error::Severity::Error,
|
||||||
|
"JSONError",
|
||||||
|
"general",
|
||||||
|
"Field \"settings.remappings\" cannot be used for Yul."
|
||||||
|
));
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
if (_inputsAndSettings.revertStrings != RevertStrings::Default)
|
||||||
|
{
|
||||||
|
output["errors"].append(formatError(
|
||||||
|
Error::Severity::Error,
|
||||||
|
"JSONError",
|
||||||
|
"general",
|
||||||
|
"Field \"settings.debug.revertStrings\" cannot be used for Yul."
|
||||||
|
));
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
_inputsAndSettings.evmVersion,
|
_inputsAndSettings.evmVersion,
|
||||||
@ -1333,16 +1366,23 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
|||||||
|
|
||||||
// Inconsistent state - stop here to receive error reports from users
|
// Inconsistent state - stop here to receive error reports from users
|
||||||
if (!stack.parseAndAnalyze(sourceName, sourceContents) && stack.errors().empty())
|
if (!stack.parseAndAnalyze(sourceName, sourceContents) && stack.errors().empty())
|
||||||
return formatFatalError("InternalCompilerError", "No error reported, but compilation failed.");
|
{
|
||||||
|
output["errors"].append(formatError(
|
||||||
|
Error::Severity::Error,
|
||||||
|
"InternalCompilerError",
|
||||||
|
"general",
|
||||||
|
"No error reported, but compilation failed."
|
||||||
|
));
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
if (!stack.errors().empty())
|
if (!stack.errors().empty())
|
||||||
{
|
{
|
||||||
Json::Value errors = Json::arrayValue;
|
|
||||||
for (auto const& error: stack.errors())
|
for (auto const& error: stack.errors())
|
||||||
{
|
{
|
||||||
auto err = dynamic_pointer_cast<Error const>(error);
|
auto err = dynamic_pointer_cast<Error const>(error);
|
||||||
|
|
||||||
errors.append(formatErrorWithException(
|
output["errors"].append(formatErrorWithException(
|
||||||
stack,
|
stack,
|
||||||
*error,
|
*error,
|
||||||
Error::errorSeverity(err->type()),
|
Error::errorSeverity(err->type()),
|
||||||
@ -1351,7 +1391,6 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
|||||||
""
|
""
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
output["errors"] = errors;
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
test/cmdlineTests/standard_yul_single_file_via_urls/args
Normal file
1
test/cmdlineTests/standard_yul_single_file_via_urls/args
Normal file
@ -0,0 +1 @@
|
|||||||
|
--pretty-json --json-indent 4 --allow-paths .
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"language": "Yul",
|
||||||
|
"sources": {
|
||||||
|
"C": {"urls": ["in.yul"]}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"errors":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"component": "general",
|
||||||
|
"formattedMessage": "Cannot import url (\"in.yul\"): File not found.",
|
||||||
|
"message": "Cannot import url (\"in.yul\"): File not found.",
|
||||||
|
"severity": "error",
|
||||||
|
"type": "IOError"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"component": "general",
|
||||||
|
"formattedMessage": "Yul mode only supports exactly one input file.",
|
||||||
|
"message": "Yul mode only supports exactly one input file.",
|
||||||
|
"severity": "error",
|
||||||
|
"type": "JSONError"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user