mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
SourceReferenceFormatter: Support full range of options in formatErrorInformation()
This commit is contained in:
parent
b7d2c8bb0a
commit
8407c8c615
@ -90,14 +90,28 @@ public:
|
|||||||
|
|
||||||
static std::string formatErrorInformation(
|
static std::string formatErrorInformation(
|
||||||
Error const& _error,
|
Error const& _error,
|
||||||
CharStreamProvider const& _charStreamProvider
|
CharStreamProvider const& _charStreamProvider,
|
||||||
|
bool _colored = false,
|
||||||
|
bool _withErrorIds = false
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return formatExceptionInformation(
|
std::ostringstream errorOutput;
|
||||||
_error,
|
SourceReferenceFormatter formatter(errorOutput, _charStreamProvider, _colored, _withErrorIds);
|
||||||
Error::errorSeverity(_error.type()),
|
formatter.printErrorInformation(_error);
|
||||||
_charStreamProvider
|
return errorOutput.str();
|
||||||
);
|
}
|
||||||
|
|
||||||
|
static std::string formatErrorInformation(
|
||||||
|
langutil::ErrorList const& _errors,
|
||||||
|
CharStreamProvider const& _charStreamProvider,
|
||||||
|
bool _colored = false,
|
||||||
|
bool _withErrorIds = false
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::ostringstream errorOutput;
|
||||||
|
SourceReferenceFormatter formatter(errorOutput, _charStreamProvider, _colored, _withErrorIds);
|
||||||
|
formatter.printErrorInformation(_errors);
|
||||||
|
return errorOutput.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string formatErrorInformation(Error const& _error, CharStream const& _charStream);
|
static std::string formatErrorInformation(Error const& _error, CharStream const& _charStream);
|
||||||
|
@ -1486,16 +1486,13 @@ void CompilerStack::generateIR(ContractDefinition const& _contract)
|
|||||||
m_optimiserSettings,
|
m_optimiserSettings,
|
||||||
m_debugInfoSelection
|
m_debugInfoSelection
|
||||||
);
|
);
|
||||||
if (!stack.parseAndAnalyze("", compiledContract.yulIR))
|
bool yulAnalysisSuccessful = stack.parseAndAnalyze("", compiledContract.yulIR);
|
||||||
{
|
solAssert(
|
||||||
string errorMessage;
|
yulAnalysisSuccessful,
|
||||||
for (auto const& error: stack.errors())
|
compiledContract.yulIR + "\n\n"
|
||||||
errorMessage += langutil::SourceReferenceFormatter::formatErrorInformation(
|
"Invalid IR generated:\n" +
|
||||||
*error,
|
langutil::SourceReferenceFormatter::formatErrorInformation(stack.errors(), stack) + "\n"
|
||||||
stack.charStream("")
|
|
||||||
);
|
);
|
||||||
solAssert(false, compiledContract.yulIR + "\n\nInvalid IR generated:\n" + errorMessage + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
compiledContract.yulIRAst = stack.astJson();
|
compiledContract.yulIRAst = stack.astJson();
|
||||||
stack.optimize();
|
stack.optimize();
|
||||||
|
@ -85,12 +85,10 @@ std::optional<Error> parseAndReturnFirstError(
|
|||||||
if (_allowWarnings && e->type() == Error::Type::Warning)
|
if (_allowWarnings && e->type() == Error::Type::Warning)
|
||||||
continue;
|
continue;
|
||||||
if (error)
|
if (error)
|
||||||
{
|
BOOST_FAIL(
|
||||||
string errors;
|
"Found more than one error:\n" +
|
||||||
for (auto const& err: stack.errors())
|
SourceReferenceFormatter::formatErrorInformation(stack.errors(), stack)
|
||||||
errors += SourceReferenceFormatter::formatErrorInformation(*err, stack);
|
);
|
||||||
BOOST_FAIL("Found more than one error:\n" + errors);
|
|
||||||
}
|
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
if (!success)
|
if (!success)
|
||||||
|
@ -42,9 +42,8 @@ optional<CompilerOutput> SolidityCompilationFramework::compileContract()
|
|||||||
if (m_compilerInput.debugFailure)
|
if (m_compilerInput.debugFailure)
|
||||||
{
|
{
|
||||||
cerr << "Compiling contract failed" << endl;
|
cerr << "Compiling contract failed" << endl;
|
||||||
for (auto const& error: m_compiler.errors())
|
|
||||||
cerr << SourceReferenceFormatter::formatErrorInformation(
|
cerr << SourceReferenceFormatter::formatErrorInformation(
|
||||||
*error,
|
m_compiler.errors(),
|
||||||
m_compiler
|
m_compiler
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user