mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
small fix
This commit is contained in:
parent
10c3d76555
commit
ebaf3c48a6
6
AST.cpp
6
AST.cpp
@ -151,7 +151,7 @@ void ContractDefinition::checkDuplicateFunctions() const
|
||||
|
||||
BOOST_THROW_EXCEPTION(
|
||||
DeclarationError() <<
|
||||
errinfo_sourceLocation(getConstructor()->getLocation()) <<
|
||||
errinfo_sourceLocation(functions[getName()].front()->getLocation()) <<
|
||||
errinfo_comment("More than one constructor defined.") <<
|
||||
errinfo_secondarySourceLocation(ssl)
|
||||
);
|
||||
@ -165,9 +165,9 @@ void ContractDefinition::checkDuplicateFunctions() const
|
||||
BOOST_THROW_EXCEPTION(
|
||||
DeclarationError() <<
|
||||
errinfo_sourceLocation(overloads[j]->getLocation()) <<
|
||||
errinfo_comment("Function with same name and arguments already defined.") <<
|
||||
errinfo_comment("Function with same name and arguments defined twice.") <<
|
||||
errinfo_secondarySourceLocation(SecondarySourceLocation().append(
|
||||
"The previous declaration is here:", overloads[i]->getLocation()))
|
||||
"Other declaration is here:", overloads[i]->getLocation()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
std::set<Declaration const*> resolveName(ASTString const& _name, bool _recursive = false) const;
|
||||
Declaration const* getEnclosingDeclaration() const { return m_enclosingDeclaration; }
|
||||
std::map<ASTString, std::set<Declaration const*>> const& getDeclarations() const { return m_declarations; }
|
||||
/// @returns weather declaration is valid, and if not also returns previous declaration.
|
||||
/// @returns whether declaration is valid, and if not also returns previous declaration.
|
||||
Declaration const* conflictingDeclaration(Declaration const& _declaration) const;
|
||||
|
||||
private:
|
||||
|
@ -44,7 +44,6 @@ using errorSourceLocationInfo = std::pair<std::string, SourceLocation>;
|
||||
class SecondarySourceLocation
|
||||
{
|
||||
public:
|
||||
//SecondarySourceLocation(){}
|
||||
SecondarySourceLocation& append(std::string const& _errMsg, SourceLocation const& _sourceLocation)
|
||||
{
|
||||
infos.push_back(std::make_pair(_errMsg, _sourceLocation));
|
||||
|
@ -357,25 +357,26 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio
|
||||
{
|
||||
SourceLocation firstDeclarationLocation;
|
||||
SourceLocation secondDeclarationLocation;
|
||||
Declaration const* conflictingDeclaration = m_scopes[m_currentScope].conflictingDeclaration(_declaration);
|
||||
solAssert(conflictingDeclaration, "");
|
||||
|
||||
if (_declaration.getLocation().start < m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation().start)
|
||||
if (_declaration.getLocation().start < conflictingDeclaration->getLocation().start)
|
||||
{
|
||||
firstDeclarationLocation = _declaration.getLocation();
|
||||
secondDeclarationLocation = m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation();
|
||||
secondDeclarationLocation = conflictingDeclaration->getLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
firstDeclarationLocation = m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation();
|
||||
firstDeclarationLocation = conflictingDeclaration->getLocation();
|
||||
secondDeclarationLocation = _declaration.getLocation();
|
||||
}
|
||||
solAssert(m_scopes[m_currentScope].conflictingDeclaration(_declaration), "");
|
||||
BOOST_THROW_EXCEPTION(DeclarationError()
|
||||
<< errinfo_sourceLocation(secondDeclarationLocation)
|
||||
<< errinfo_comment("Identifier already declared.")
|
||||
<< errinfo_secondarySourceLocation(SecondarySourceLocation().append(
|
||||
"The previous declaration is here:",
|
||||
firstDeclarationLocation
|
||||
)));
|
||||
|
||||
BOOST_THROW_EXCEPTION(
|
||||
DeclarationError() <<
|
||||
errinfo_sourceLocation(secondDeclarationLocation) <<
|
||||
errinfo_comment("Identifier already declared.") <<
|
||||
errinfo_secondarySourceLocation(
|
||||
SecondarySourceLocation().append("The previous declaration is here:", firstDeclarationLocation)));
|
||||
}
|
||||
|
||||
_declaration.setScope(m_currentScope);
|
||||
@ -456,8 +457,11 @@ bool ReferencesResolver::visit(Identifier& _identifier)
|
||||
{
|
||||
auto declarations = m_resolver.getNameFromCurrentScope(_identifier.getName());
|
||||
if (declarations.empty())
|
||||
BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_sourceLocation(_identifier.getLocation())
|
||||
<< errinfo_comment("Undeclared identifier."));
|
||||
BOOST_THROW_EXCEPTION(
|
||||
DeclarationError() <<
|
||||
errinfo_sourceLocation(_identifier.getLocation()) <<
|
||||
errinfo_comment("Undeclared identifier.")
|
||||
);
|
||||
else if (declarations.size() == 1)
|
||||
_identifier.setReferencedDeclaration(**declarations.begin(), m_currentContract);
|
||||
else
|
||||
|
@ -32,9 +32,11 @@ namespace dev
|
||||
namespace solidity
|
||||
{
|
||||
|
||||
void SourceReferenceFormatter::printSourceLocation(ostream& _stream,
|
||||
SourceLocation const& _location,
|
||||
Scanner const& _scanner)
|
||||
void SourceReferenceFormatter::printSourceLocation(
|
||||
ostream& _stream,
|
||||
SourceLocation const& _location,
|
||||
Scanner const& _scanner
|
||||
)
|
||||
{
|
||||
int startLine;
|
||||
int startColumn;
|
||||
@ -64,9 +66,11 @@ void SourceReferenceFormatter::printSourceLocation(ostream& _stream,
|
||||
<< "Spanning multiple lines.\n";
|
||||
}
|
||||
|
||||
void SourceReferenceFormatter::printSourceName(ostream& _stream,
|
||||
SourceLocation const& _location,
|
||||
Scanner const& _scanner)
|
||||
void SourceReferenceFormatter::printSourceName(
|
||||
ostream& _stream,
|
||||
SourceLocation const& _location,
|
||||
Scanner const& _scanner
|
||||
)
|
||||
{
|
||||
int startLine;
|
||||
int startColumn;
|
||||
@ -74,14 +78,16 @@ void SourceReferenceFormatter::printSourceName(ostream& _stream,
|
||||
_stream << *_location.sourceName << ":" << (startLine + 1) << ":" << (startColumn + 1) << ": ";
|
||||
}
|
||||
|
||||
void SourceReferenceFormatter::printExceptionInformation(ostream& _stream,
|
||||
Exception const& _exception,
|
||||
string const& _name,
|
||||
CompilerStack const& _compiler)
|
||||
void SourceReferenceFormatter::printExceptionInformation(
|
||||
ostream& _stream,
|
||||
Exception const& _exception,
|
||||
string const& _name,
|
||||
CompilerStack const& _compiler
|
||||
)
|
||||
{
|
||||
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(_exception);
|
||||
auto secondarylocation = boost::get_error_info<errinfo_secondarySourceLocation>(_exception);
|
||||
Scanner const* scanner;
|
||||
Scanner const* scanner = nullptr;
|
||||
|
||||
if (location)
|
||||
{
|
||||
@ -101,7 +107,7 @@ void SourceReferenceFormatter::printExceptionInformation(ostream& _stream,
|
||||
|
||||
if (secondarylocation && !secondarylocation->infos.empty())
|
||||
{
|
||||
for(auto info: secondarylocation->infos)
|
||||
for (auto info: secondarylocation->infos)
|
||||
{
|
||||
scanner = &_compiler.getScanner(*info.second.sourceName);
|
||||
_stream << info.first << " ";
|
||||
|
@ -40,8 +40,12 @@ struct SourceReferenceFormatter
|
||||
{
|
||||
public:
|
||||
static void printSourceLocation(std::ostream& _stream, SourceLocation const& _location, Scanner const& _scanner);
|
||||
static void printExceptionInformation(std::ostream& _stream, Exception const& _exception,
|
||||
std::string const& _name, CompilerStack const& _compiler);
|
||||
static void printExceptionInformation(
|
||||
std::ostream& _stream,
|
||||
Exception const& _exception,
|
||||
std::string const& _name,
|
||||
CompilerStack const& _compiler
|
||||
);
|
||||
private:
|
||||
static void printSourceName(std::ostream& _stream, SourceLocation const& _location, Scanner const& _scanner);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user