Skip to content

Commit

Permalink
Report more info when an unreported fatal error is caught
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Jan 31, 2025
1 parent dd95386 commit 59e1a1c
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 12 deletions.
27 changes: 21 additions & 6 deletions libsolidity/analysis/NameAndTypeResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ bool NameAndTypeResolver::registerDeclarations(SourceUnit& _sourceUnit, ASTNode
{
DeclarationRegistrationHelper registrar(m_scopes, _sourceUnit, m_errorReporter, m_globalContext, _currentScope);
}
catch (langutil::FatalError const& error)
catch (FatalError const& error)
{
solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
solAssert(false, "Unreported fatal error.");
}
return false;
}
return true;
Expand Down Expand Up @@ -135,9 +140,14 @@ bool NameAndTypeResolver::resolveNamesAndTypes(SourceUnit& _source)
return false;
}
}
catch (langutil::FatalError const& error)
catch (FatalError const& error)
{
solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
solAssert(false, "Unreported fatal error.");
}
return false;
}
return true;
Expand All @@ -150,9 +160,14 @@ bool NameAndTypeResolver::updateDeclaration(Declaration const& _declaration)
m_scopes[nullptr]->registerDeclaration(_declaration, false, true);
solAssert(_declaration.scope() == nullptr, "Updated declaration outside global scope.");
}
catch (langutil::FatalError const& error)
catch (FatalError const& error)
{
solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
solAssert(false, "Unreported fatal error.");
}
return false;
}
return true;
Expand Down
14 changes: 12 additions & 2 deletions libsolidity/interface/CompilerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,12 @@ bool CompilerStack::analyze()
}
catch (FatalError const& error)
{
solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
solAssert(false, "Unreported fatal error.");
}
noErrors = false;
}
catch (UnimplementedFeatureError const& _error)
Expand Down Expand Up @@ -1318,7 +1323,12 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast)
}
catch (FatalError const& error)
{
solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
solAssert(false, "Unreported fatal error.");
}
}
return newSources;
}
Expand Down
7 changes: 6 additions & 1 deletion libsolidity/parsing/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ ASTPointer<SourceUnit> Parser::parse(CharStream& _charStream)
}
catch (FatalError const& error)
{
solAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
solAssert(false, "Unreported fatal error.");
}
return nullptr;
}
}
Expand Down
7 changes: 6 additions & 1 deletion libyul/AsmAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ bool AsmAnalyzer::analyze(Block const& _block)
// we exceed it because the reporter keeps counting (it just stops adding errors to the list).
// Note also that fact of exceeding the cap triggers a FatalError so one can get thrown even
// if we don't make any of our errors fatal.
yulAssert(!watcher.ok(), "Unreported fatal error: "s + error.what());
if (watcher.ok())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
yulAssert(false, "Unreported fatal error.");
}
}
return watcher.ok();
}
Expand Down
7 changes: 6 additions & 1 deletion libyul/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ std::unique_ptr<AST> Parser::parseInline(std::shared_ptr<Scanner> const& _scanne
}
catch (FatalError const& error)
{
yulAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
yulAssert(false, "Unreported fatal error.");
}
}

return nullptr;
Expand Down
7 changes: 6 additions & 1 deletion libyul/ObjectParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ std::shared_ptr<Object> ObjectParser::parse(std::shared_ptr<Scanner> const& _sca
}
catch (FatalError const& error)
{
yulAssert(m_errorReporter.hasErrors(), "Unreported fatal error: "s + error.what());
if (!m_errorReporter.hasErrors())
{
std::cerr << "Unreported fatal error:" << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
yulAssert(false, "Unreported fatal error.");
}
}
return nullptr;
}
Expand Down

0 comments on commit 59e1a1c

Please sign in to comment.