From b85d4789316225145c44515dfe8cf2ed30670e21 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 21 Jun 2018 20:15:02 +0200 Subject: [PATCH] Add assertion for contract name clash in the resolver in CompilerStack --- libsolidity/interface/CompilerStack.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 1474b2826..0c2e303cd 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -310,12 +310,19 @@ bool CompilerStack::analyze() if (!resolver.resolveNamesAndTypes(*node)) return false; if (ContractDefinition* contract = dynamic_cast(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