|
@ -357,25 +357,26 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio |
|
|
{ |
|
|
{ |
|
|
SourceLocation firstDeclarationLocation; |
|
|
SourceLocation firstDeclarationLocation; |
|
|
SourceLocation secondDeclarationLocation; |
|
|
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(); |
|
|
firstDeclarationLocation = _declaration.getLocation(); |
|
|
secondDeclarationLocation = m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation(); |
|
|
secondDeclarationLocation = conflictingDeclaration->getLocation(); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
firstDeclarationLocation = m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation(); |
|
|
firstDeclarationLocation = conflictingDeclaration->getLocation(); |
|
|
secondDeclarationLocation = _declaration.getLocation(); |
|
|
secondDeclarationLocation = _declaration.getLocation(); |
|
|
} |
|
|
} |
|
|
solAssert(m_scopes[m_currentScope].conflictingDeclaration(_declaration), ""); |
|
|
|
|
|
BOOST_THROW_EXCEPTION(DeclarationError() |
|
|
BOOST_THROW_EXCEPTION( |
|
|
<< errinfo_sourceLocation(secondDeclarationLocation) |
|
|
DeclarationError() << |
|
|
<< errinfo_comment("Identifier already declared.") |
|
|
errinfo_sourceLocation(secondDeclarationLocation) << |
|
|
<< errinfo_secondarySourceLocation(SecondarySourceLocation().append( |
|
|
errinfo_comment("Identifier already declared.") << |
|
|
"The previous declaration is here:", |
|
|
errinfo_secondarySourceLocation( |
|
|
firstDeclarationLocation |
|
|
SecondarySourceLocation().append("The previous declaration is here:", firstDeclarationLocation))); |
|
|
))); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_declaration.setScope(m_currentScope); |
|
|
_declaration.setScope(m_currentScope); |
|
@ -456,8 +457,11 @@ bool ReferencesResolver::visit(Identifier& _identifier) |
|
|
{ |
|
|
{ |
|
|
auto declarations = m_resolver.getNameFromCurrentScope(_identifier.getName()); |
|
|
auto declarations = m_resolver.getNameFromCurrentScope(_identifier.getName()); |
|
|
if (declarations.empty()) |
|
|
if (declarations.empty()) |
|
|
BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_sourceLocation(_identifier.getLocation()) |
|
|
BOOST_THROW_EXCEPTION( |
|
|
<< errinfo_comment("Undeclared identifier.")); |
|
|
DeclarationError() << |
|
|
|
|
|
errinfo_sourceLocation(_identifier.getLocation()) << |
|
|
|
|
|
errinfo_comment("Undeclared identifier.") |
|
|
|
|
|
); |
|
|
else if (declarations.size() == 1) |
|
|
else if (declarations.size() == 1) |
|
|
_identifier.setReferencedDeclaration(**declarations.begin(), m_currentContract); |
|
|
_identifier.setReferencedDeclaration(**declarations.begin(), m_currentContract); |
|
|
else |
|
|
else |
|
|