From ebaf3c48a64ce7bbd6643b1d115d1c59005d15ec Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 15:46:46 +0200 Subject: small fix --- NameAndTypeResolver.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'NameAndTypeResolver.cpp') diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp index a81c8238..813e0452 100644 --- a/NameAndTypeResolver.cpp +++ b/NameAndTypeResolver.cpp @@ -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 -- cgit v1.2.3