Merge pull request #7918 from ethereum/compilerstack-fqdn

Add assertion for contract name clash in the resolver in CompilerStack
This commit is contained in:
chriseth 2020-01-15 18:00:58 +01:00 committed by GitHub
commit 185a736e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -332,12 +332,19 @@ bool CompilerStack::analyze()
if (!resolver.resolveNamesAndTypes(*node))
return false;
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
// Note that we now reference contracts by their fully qualified names, and
// thus contracts can only conflict if declared in the same source file. This
// already causes a double-declaration error elsewhere, so we do not report
// an error here and instead silently drop any additional contracts we find.
// thus contracts can only conflict if declared in the same source file. This
// should already cause a double-declaration error elsewhere.
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
m_contracts[contract->fullyQualifiedName()].contract = contract;
else
solAssert(
m_errorReporter.hasErrors(),
"Contract already present (name clash?), but no error was reported."
);
}
}
// Next, we check inheritance, overrides, function collisions and other things at