Remove unique error for contract collision

Because contracts are uniquely identified by their source unit, there
is no need for a unique error for this; it's actually covered by the
checker for double-declaration of identifiers.
This commit is contained in:
Rhett Aultman 2016-12-20 04:57:46 -08:00 committed by Rhett Aultman
parent f8914c6b28
commit 85c55c796a

View File

@ -182,25 +182,12 @@ bool CompilerStack::parse()
if (!resolver.updateDeclaration(*m_globalContext->currentSuper())) return false;
if (!resolver.resolveNamesAndTypes(*contract)) return false;
if (m_contracts.find(contract->fullyQualifiedName()) != m_contracts.end())
{
ContractDefinition const* existingContract = m_contracts[contract->fullyQualifiedName()].contract;
if (contract != existingContract)
{
auto err = make_shared<Error>(Error::Type::DeclarationError);
*err <<
errinfo_sourceLocation(contract->location()) <<
errinfo_comment(
"Contract/Library \"" + contract->name() + "\" declared twice "
) <<
errinfo_secondarySourceLocation(SecondarySourceLocation().append(
"The other declaration is here:", existingContract->location()));
// 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.
m_errors.push_back(err);
noErrors = false;
}
}
else
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
m_contracts[contract->fullyQualifiedName()].contract = contract;
}
@ -222,28 +209,12 @@ bool CompilerStack::parse()
else
noErrors = false;
// Note that find() must be used here to prevent an automatic insert into the map
if (m_contracts.find(contract->fullyQualifiedName()) != m_contracts.end())
{
ContractDefinition const* existingContract = m_contracts[contract->fullyQualifiedName()].contract;
// 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.
if (contract != existingContract)
{
auto err = make_shared<Error>(Error::Type::DeclarationError);
*err <<
errinfo_sourceLocation(contract->location()) <<
errinfo_comment(
"Contract/Library \"" + contract->name() + "\" declared twice "
) <<
errinfo_secondarySourceLocation(SecondarySourceLocation().append(
"The other declaration is here:", existingContract->location()));
m_errors.push_back(err);
noErrors = false;
}
}
else
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
m_contracts[contract->fullyQualifiedName()].contract = contract;
}