analysis: report errors when inheritance causes collision

This commit is contained in:
Yoichi Hirai 2016-11-01 17:18:00 +01:00
parent fa157883f5
commit bff76c1ca0
No known key found for this signature in database
GPG Key ID: E7B75D080FCF7992

View File

@ -289,7 +289,31 @@ void NameAndTypeResolver::importInheritedScope(ContractDefinition const& _base)
for (auto const& declaration: nameAndDeclaration.second)
// Import if it was declared in the base, is not the constructor and is visible in derived classes
if (declaration->scope() == &_base && declaration->isVisibleInDerivedContracts())
m_currentScope->registerDeclaration(*declaration);
if (!m_currentScope->registerDeclaration(*declaration))
{
SourceLocation firstDeclarationLocation;
SourceLocation secondDeclarationLocation;
Declaration const* conflictingDeclaration = m_currentScope->conflictingDeclaration(*declaration);
solAssert(conflictingDeclaration, "");
if (declaration->location().start < conflictingDeclaration->location().start)
{
firstDeclarationLocation = declaration->location();
secondDeclarationLocation = conflictingDeclaration->location();
}
else
{
firstDeclarationLocation = conflictingDeclaration->location();
secondDeclarationLocation = declaration->location();
}
reportDeclarationError(
secondDeclarationLocation,
"Identifier already declared.",
firstDeclarationLocation,
"The previous declaration is here:"
);
}
}
void NameAndTypeResolver::linearizeBaseContracts(ContractDefinition& _contract)