From da309c3853bdaff02aad2d7eecd227b3d41ed4df Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 30 Apr 2015 18:06:04 +0200 Subject: [PATCH 1/8] created secondarySoureLocation error type added additional information to error msgs --- libsolidity/AST.cpp | 18 ++++++++-- libsolidity/DeclarationContainer.cpp | 42 ++++++++++++++---------- libsolidity/DeclarationContainer.h | 4 ++- libsolidity/Exceptions.h | 17 ++++++++++ libsolidity/NameAndTypeResolver.cpp | 12 +++++-- libsolidity/SourceReferenceFormatter.cpp | 33 ++++++++++++++++--- libsolidity/SourceReferenceFormatter.h | 2 ++ 7 files changed, 100 insertions(+), 28 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 09f98dca3..be64c698f 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -140,12 +140,22 @@ void ContractDefinition::checkDuplicateFunctions() const map> functions; for (ASTPointer const& function: getDefinedFunctions()) functions[function->getName()].push_back(function.get()); + if (functions[getName()].size() > 1) + { + SecondarySourceLocation ssl; + auto it = functions[getName()].begin(); + ++it; + for(; it != functions[getName()].end(); ++it) + ssl.append("Another declaration is here:", (*it)->getLocation()); + BOOST_THROW_EXCEPTION( DeclarationError() << - errinfo_sourceLocation(getLocation()) << - errinfo_comment("More than one constructor defined.") + errinfo_sourceLocation(getConstructor()->getLocation()) << + errinfo_comment("More than one constructor defined.") << + errinfo_secondarySourceLocation(ssl) ); + } for (auto const& it: functions) { vector const& overloads = it.second; @@ -155,7 +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 already defined.") << + errinfo_secondarySourceLocation(SecondarySourceLocation().append( + "The previous declaration is here:", overloads[i]->getLocation())) ); } } diff --git a/libsolidity/DeclarationContainer.cpp b/libsolidity/DeclarationContainer.cpp index 2130f3a01..c836663c7 100644 --- a/libsolidity/DeclarationContainer.cpp +++ b/libsolidity/DeclarationContainer.cpp @@ -28,6 +28,28 @@ using namespace std; using namespace dev; using namespace dev::solidity; +Declaration const* DeclarationContainer::conflictingDeclaration(Declaration const& _declaration) const +{ + ASTString const& name(_declaration.getName()); + solAssert(!name.empty(), ""); + vector declarations; + if (m_declarations.count(name)) + declarations += m_declarations.at(name); + if (m_invisibleDeclarations.count(name)) + declarations += m_invisibleDeclarations.at(name); + if (dynamic_cast(&_declaration)) + { + // check that all other declarations with the same name are functions + for (Declaration const* declaration: declarations) + if (!dynamic_cast(declaration)) + return declaration; + } + else if (!declarations.empty()) + return declarations.front(); + + return nullptr; +} + bool DeclarationContainer::registerDeclaration(Declaration const& _declaration, bool _invisible, bool _update) { ASTString const& name(_declaration.getName()); @@ -40,24 +62,8 @@ bool DeclarationContainer::registerDeclaration(Declaration const& _declaration, m_declarations.erase(name); m_invisibleDeclarations.erase(name); } - else - { - vector declarations; - if (m_declarations.count(name)) - declarations += m_declarations.at(name); - if (m_invisibleDeclarations.count(name)) - declarations += m_invisibleDeclarations.at(name); - if (dynamic_cast(&_declaration)) - { - // check that all other declarations with the same name are functions - - for (Declaration const* declaration: declarations) - if (!dynamic_cast(declaration)) - return false; - } - else if (!declarations.empty()) - return false; - } + else if (conflictingDeclaration(_declaration)) + return false; if (_invisible) m_invisibleDeclarations[name].insert(&_declaration); diff --git a/libsolidity/DeclarationContainer.h b/libsolidity/DeclarationContainer.h index 35a6ea077..9ae25880a 100644 --- a/libsolidity/DeclarationContainer.h +++ b/libsolidity/DeclarationContainer.h @@ -34,7 +34,7 @@ namespace solidity { /** - * Container that stores mappings betwee names and declarations. It also contains a link to the + * Container that stores mappings between names and declarations. It also contains a link to the * enclosing scope. */ class DeclarationContainer @@ -51,6 +51,8 @@ public: std::set resolveName(ASTString const& _name, bool _recursive = false) const; Declaration const* getEnclosingDeclaration() const { return m_enclosingDeclaration; } std::map> const& getDeclarations() const { return m_declarations; } + /// @returns weather declaration is valid, and if not also returns previous declaration. + Declaration const* conflictingDeclaration(Declaration const& _declaration) const; private: Declaration const* m_enclosingDeclaration; diff --git a/libsolidity/Exceptions.h b/libsolidity/Exceptions.h index 0d07c7064..51106c2b6 100644 --- a/libsolidity/Exceptions.h +++ b/libsolidity/Exceptions.h @@ -23,6 +23,7 @@ #pragma once #include +#include #include #include @@ -38,7 +39,23 @@ struct CompilerError: virtual Exception {}; struct InternalCompilerError: virtual Exception {}; struct DocstringParsingError: virtual Exception {}; +using errorSourceLocationInfo = std::pair; + +class SecondarySourceLocation +{ +public: + //SecondarySourceLocation(){} + SecondarySourceLocation& append(std::string const& _errMsg, SourceLocation const& _sourceLocation) + { + infos.push_back(std::make_pair(_errMsg, _sourceLocation)); + return *this; + } + + std::vector infos; +}; + using errinfo_sourceLocation = boost::error_info; +using errinfo_secondarySourceLocation = boost::error_info; } } diff --git a/libsolidity/NameAndTypeResolver.cpp b/libsolidity/NameAndTypeResolver.cpp index a286934a9..56e81e372 100644 --- a/libsolidity/NameAndTypeResolver.cpp +++ b/libsolidity/NameAndTypeResolver.cpp @@ -354,8 +354,16 @@ void DeclarationRegistrationHelper::closeCurrentScope() void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaration, bool _opensScope) { if (!m_scopes[m_currentScope].registerDeclaration(_declaration, !_declaration.isVisibleInContract())) - BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_sourceLocation(_declaration.getLocation()) - << errinfo_comment("Identifier already declared.")); + { + solAssert(m_scopes[m_currentScope].conflictingDeclaration(_declaration), ""); + BOOST_THROW_EXCEPTION(DeclarationError() + << errinfo_sourceLocation(_declaration.getLocation()) + << errinfo_comment("Identifier already declared.") + << errinfo_secondarySourceLocation(SecondarySourceLocation().append( + "The previous declaration is here:", + m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation()))); + } + //@todo the exception should also contain the location of the first declaration _declaration.setScope(m_currentScope); if (_opensScope) diff --git a/libsolidity/SourceReferenceFormatter.cpp b/libsolidity/SourceReferenceFormatter.cpp index b5e83b8c9..a30621a1e 100644 --- a/libsolidity/SourceReferenceFormatter.cpp +++ b/libsolidity/SourceReferenceFormatter.cpp @@ -64,28 +64,53 @@ void SourceReferenceFormatter::printSourceLocation(ostream& _stream, << "Spanning multiple lines.\n"; } +void SourceReferenceFormatter::printSourceName(ostream& _stream, + SourceLocation const& _location, + Scanner const& _scanner) +{ + int startLine; + int startColumn; + tie(startLine, startColumn) = _scanner.translatePositionToLineColumn(_location.start); + _stream << *_location.sourceName << ":" << (startLine + 1) << ":" << (startColumn + 1) << ": "; +} + void SourceReferenceFormatter::printExceptionInformation(ostream& _stream, Exception const& _exception, string const& _name, CompilerStack const& _compiler) { SourceLocation const* location = boost::get_error_info(_exception); + auto secondarylocation = boost::get_error_info(_exception); Scanner const* scanner; if (location) { scanner = &_compiler.getScanner(*location->sourceName); - int startLine; - int startColumn; - tie(startLine, startColumn) = scanner->translatePositionToLineColumn(location->start); - _stream << *location->sourceName << ":" << (startLine + 1) << ":" << (startColumn + 1) << ": "; + printSourceName(_stream, *location, *scanner); } + _stream << _name; if (string const* description = boost::get_error_info(_exception)) _stream << ": " << *description << endl; if (location) + { + solAssert(scanner, ""); printSourceLocation(_stream, *location, *scanner); + } + + if (secondarylocation && !secondarylocation->infos.empty()) + { + for(auto info: secondarylocation->infos) + { + scanner = &_compiler.getScanner(*info.second.sourceName); + _stream << info.first << " "; + printSourceName(_stream, info.second, *scanner); + _stream << endl; + printSourceLocation(_stream, info.second, *scanner); + } + _stream << endl; + } } } diff --git a/libsolidity/SourceReferenceFormatter.h b/libsolidity/SourceReferenceFormatter.h index 304e6a273..43d3882e8 100644 --- a/libsolidity/SourceReferenceFormatter.h +++ b/libsolidity/SourceReferenceFormatter.h @@ -42,6 +42,8 @@ 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); +private: + static void printSourceName(std::ostream& _stream, SourceLocation const& _location, Scanner const& _scanner); }; } From 7b72aa68be391f7a0f83a0beed38f5670650eedd Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 14:46:52 +0200 Subject: [PATCH 2/8] fixed the order of error msgs --- libsolidity/NameAndTypeResolver.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libsolidity/NameAndTypeResolver.cpp b/libsolidity/NameAndTypeResolver.cpp index 56e81e372..a81c82380 100644 --- a/libsolidity/NameAndTypeResolver.cpp +++ b/libsolidity/NameAndTypeResolver.cpp @@ -355,16 +355,29 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio { if (!m_scopes[m_currentScope].registerDeclaration(_declaration, !_declaration.isVisibleInContract())) { + SourceLocation firstDeclarationLocation; + SourceLocation secondDeclarationLocation; + + if (_declaration.getLocation().start < m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation().start) + { + firstDeclarationLocation = _declaration.getLocation(); + secondDeclarationLocation = m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation(); + } + else + { + firstDeclarationLocation = m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation(); + secondDeclarationLocation = _declaration.getLocation(); + } solAssert(m_scopes[m_currentScope].conflictingDeclaration(_declaration), ""); BOOST_THROW_EXCEPTION(DeclarationError() - << errinfo_sourceLocation(_declaration.getLocation()) + << errinfo_sourceLocation(secondDeclarationLocation) << errinfo_comment("Identifier already declared.") << errinfo_secondarySourceLocation(SecondarySourceLocation().append( "The previous declaration is here:", - m_scopes[m_currentScope].conflictingDeclaration(_declaration)->getLocation()))); + firstDeclarationLocation + ))); } - //@todo the exception should also contain the location of the first declaration _declaration.setScope(m_currentScope); if (_opensScope) enterNewSubScope(_declaration); From 0702c5836810839bff6ccec7f290da88f076ea4b Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 15:03:15 +0200 Subject: [PATCH 3/8] fixed warrning --- libsolidity/SourceReferenceFormatter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsolidity/SourceReferenceFormatter.cpp b/libsolidity/SourceReferenceFormatter.cpp index a30621a1e..87796aa32 100644 --- a/libsolidity/SourceReferenceFormatter.cpp +++ b/libsolidity/SourceReferenceFormatter.cpp @@ -95,7 +95,7 @@ void SourceReferenceFormatter::printExceptionInformation(ostream& _stream, if (location) { - solAssert(scanner, ""); + scanner = &_compiler.getScanner(*location->sourceName); printSourceLocation(_stream, *location, *scanner); } From 1c6fcca6e2453152ae7d73d7231551f31b8587d1 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 15:46:46 +0200 Subject: [PATCH 4/8] small fix --- libsolidity/AST.cpp | 6 ++--- libsolidity/DeclarationContainer.h | 2 +- libsolidity/Exceptions.h | 1 - libsolidity/NameAndTypeResolver.cpp | 30 ++++++++++++++---------- libsolidity/SourceReferenceFormatter.cpp | 30 ++++++++++++++---------- libsolidity/SourceReferenceFormatter.h | 8 +++++-- 6 files changed, 45 insertions(+), 32 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index be64c698f..50184fa5a 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/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())) ); } } diff --git a/libsolidity/DeclarationContainer.h b/libsolidity/DeclarationContainer.h index 9ae25880a..94545eefb 100644 --- a/libsolidity/DeclarationContainer.h +++ b/libsolidity/DeclarationContainer.h @@ -51,7 +51,7 @@ public: std::set resolveName(ASTString const& _name, bool _recursive = false) const; Declaration const* getEnclosingDeclaration() const { return m_enclosingDeclaration; } std::map> 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: diff --git a/libsolidity/Exceptions.h b/libsolidity/Exceptions.h index 51106c2b6..a0031ba7e 100644 --- a/libsolidity/Exceptions.h +++ b/libsolidity/Exceptions.h @@ -44,7 +44,6 @@ using errorSourceLocationInfo = std::pair; class SecondarySourceLocation { public: - //SecondarySourceLocation(){} SecondarySourceLocation& append(std::string const& _errMsg, SourceLocation const& _sourceLocation) { infos.push_back(std::make_pair(_errMsg, _sourceLocation)); diff --git a/libsolidity/NameAndTypeResolver.cpp b/libsolidity/NameAndTypeResolver.cpp index a81c82380..813e04526 100644 --- a/libsolidity/NameAndTypeResolver.cpp +++ b/libsolidity/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 diff --git a/libsolidity/SourceReferenceFormatter.cpp b/libsolidity/SourceReferenceFormatter.cpp index 87796aa32..e66851358 100644 --- a/libsolidity/SourceReferenceFormatter.cpp +++ b/libsolidity/SourceReferenceFormatter.cpp @@ -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(_exception); auto secondarylocation = boost::get_error_info(_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 << " "; diff --git a/libsolidity/SourceReferenceFormatter.h b/libsolidity/SourceReferenceFormatter.h index 43d3882e8..ed2564f31 100644 --- a/libsolidity/SourceReferenceFormatter.h +++ b/libsolidity/SourceReferenceFormatter.h @@ -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); }; From f4b836dab3950506ad7f2a83aa7c7adb1d51ecc3 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 17:18:01 +0200 Subject: [PATCH 5/8] some more style fixes --- libsolidity/AST.cpp | 13 +++++++------ libsolidity/SourceReferenceFormatter.cpp | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 50184fa5a..da34f3ab9 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -95,9 +95,10 @@ void ContractDefinition::checkTypeRequirements() { FixedHash<4> const& hash = it.first; if (hashes.count(hash)) - BOOST_THROW_EXCEPTION(createTypeError( - std::string("Function signature hash collision for ") + - it.second->externalSignature())); + BOOST_THROW_EXCEPTION( + createTypeError( + string("Function signature hash collision for ") + it.second->externalSignature()) + ); hashes.insert(hash); } } @@ -311,12 +312,12 @@ void ContractDefinition::checkExternalTypeClashes() const )); } -std::vector> const& ContractDefinition::getInterfaceEvents() const +vector> const& ContractDefinition::getInterfaceEvents() const { if (!m_interfaceEvents) { set eventsSeen; - m_interfaceEvents.reset(new std::vector>()); + m_interfaceEvents.reset(new vector>()); for (ContractDefinition const* contract: getLinearizedBaseContracts()) for (ASTPointer const& e: contract->getEvents()) if (eventsSeen.count(e->getName()) == 0) @@ -956,7 +957,7 @@ void Identifier::overloadResolution(TypePointers const& _argumentTypes) solAssert(!m_referencedDeclaration, "Referenced declaration should be null before overload resolution."); solAssert(!m_overloadedDeclarations.empty(), "No candidates for overload resolution found."); - std::vector possibles; + vector possibles; if (m_overloadedDeclarations.size() == 1) m_referencedDeclaration = *m_overloadedDeclarations.begin(); diff --git a/libsolidity/SourceReferenceFormatter.cpp b/libsolidity/SourceReferenceFormatter.cpp index e66851358..77805efc8 100644 --- a/libsolidity/SourceReferenceFormatter.cpp +++ b/libsolidity/SourceReferenceFormatter.cpp @@ -48,11 +48,11 @@ void SourceReferenceFormatter::printSourceLocation( { string line = _scanner.getLineAtPosition(_location.start); _stream << line << endl; - std::for_each(line.cbegin(), line.cbegin() + startColumn, - [&_stream](char const& ch) - { - _stream << (ch == '\t' ? '\t' : ' '); - }); + for_each( + line.cbegin(), + line.cbegin() + startColumn, + [&_stream](char const& ch) { _stream << (ch == '\t' ? '\t' : ' '); } + ); _stream << "^"; if (endColumn > startColumn + 2) _stream << string(endColumn - startColumn - 2, '-'); @@ -61,9 +61,12 @@ void SourceReferenceFormatter::printSourceLocation( _stream << endl; } else - _stream << _scanner.getLineAtPosition(_location.start) << endl - << string(startColumn, ' ') << "^\n" - << "Spanning multiple lines.\n"; + _stream << + _scanner.getLineAtPosition(_location.start) << + endl << + string(startColumn, ' ') << + "^\n" << + "Spanning multiple lines.\n"; } void SourceReferenceFormatter::printSourceName( From e25c6beb274c752b586d0c5a097aebf2e10bfc00 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 17:21:59 +0200 Subject: [PATCH 6/8] Update AST.cpp --- libsolidity/AST.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index da34f3ab9..4e87e68f0 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -147,7 +147,7 @@ void ContractDefinition::checkDuplicateFunctions() const SecondarySourceLocation ssl; auto it = functions[getName()].begin(); ++it; - for(; it != functions[getName()].end(); ++it) + for (; it != functions[getName()].end(); ++it) ssl.append("Another declaration is here:", (*it)->getLocation()); BOOST_THROW_EXCEPTION( From abab0a744efb8d4c22e67d60043b1742ffa5f9e1 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 17:28:28 +0200 Subject: [PATCH 7/8] Update AST.cpp --- libsolidity/AST.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 4e87e68f0..2f98ce4f6 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -95,10 +95,9 @@ void ContractDefinition::checkTypeRequirements() { FixedHash<4> const& hash = it.first; if (hashes.count(hash)) - BOOST_THROW_EXCEPTION( - createTypeError( - string("Function signature hash collision for ") + it.second->externalSignature()) - ); + BOOST_THROW_EXCEPTION(createTypeError( + string("Function signature hash collision for ") + it.second->externalSignature() + )); hashes.insert(hash); } } From 3cfe1cabda16fa8fd9ca8a466643dce62dc1172a Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 4 May 2015 17:30:28 +0200 Subject: [PATCH 8/8] Update NameAndTypeResolver.cpp --- libsolidity/NameAndTypeResolver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsolidity/NameAndTypeResolver.cpp b/libsolidity/NameAndTypeResolver.cpp index 813e04526..9aebbf054 100644 --- a/libsolidity/NameAndTypeResolver.cpp +++ b/libsolidity/NameAndTypeResolver.cpp @@ -376,7 +376,9 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio errinfo_sourceLocation(secondDeclarationLocation) << errinfo_comment("Identifier already declared.") << errinfo_secondarySourceLocation( - SecondarySourceLocation().append("The previous declaration is here:", firstDeclarationLocation))); + SecondarySourceLocation().append("The previous declaration is here:", firstDeclarationLocation) + ) + ); } _declaration.setScope(m_currentScope);