aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface/StandardCompiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/interface/StandardCompiler.cpp')
-rw-r--r--libsolidity/interface/StandardCompiler.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index 2e5005b8..15bb7592 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -71,7 +71,7 @@ Json::Value formatErrorWithException(
)
{
string message;
- string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _message, _scannerFromSourceName);
+ string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _type, _scannerFromSourceName);
// NOTE: the below is partially a copy from SourceReferenceFormatter
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(_exception);
@@ -265,20 +265,18 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compilerStack.scanner(_sourceName); };
- bool success = false;
-
try
{
- success = m_compilerStack.compile(optimize, optimizeRuns, libraries);
+ m_compilerStack.compile(optimize, optimizeRuns, libraries);
for (auto const& error: m_compilerStack.errors())
{
- auto err = dynamic_pointer_cast<Error const>(error);
+ Error const& err = dynamic_cast<Error const&>(*error);
errors.append(formatErrorWithException(
*error,
- err->type() == Error::Type::Warning,
- err->typeName(),
+ err.type() == Error::Type::Warning,
+ err.typeName(),
"general",
"",
scannerFromSourceName
@@ -359,13 +357,16 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
if (errors.size() > 0)
output["errors"] = errors;
+ bool analysisSuccess = m_compilerStack.state() >= CompilerStack::State::AnalysisSuccessful;
+ bool compilationSuccess = m_compilerStack.state() == CompilerStack::State::CompilationSuccessful;
+
/// Inconsistent state - stop here to receive error reports from users
- if (!success && (errors.size() == 0))
+ if (!compilationSuccess && (errors.size() == 0))
return formatFatalError("InternalCompilerError", "No error reported, but compilation failed.");
output["sources"] = Json::objectValue;
unsigned sourceIndex = 0;
- for (auto const& source: m_compilerStack.sourceNames())
+ for (auto const& source: analysisSuccess ? m_compilerStack.sourceNames() : vector<string>())
{
Json::Value sourceResult = Json::objectValue;
sourceResult["id"] = sourceIndex++;
@@ -375,7 +376,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
}
Json::Value contractsOutput = Json::objectValue;
- for (string const& contractName: success ? m_compilerStack.contractNames() : vector<string>())
+ for (string const& contractName: compilationSuccess ? m_compilerStack.contractNames() : vector<string>())
{
size_t colon = contractName.find(':');
solAssert(colon != string::npos, "");