mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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:
parent
f8914c6b28
commit
85c55c796a
@ -182,25 +182,12 @@ bool CompilerStack::parse()
|
|||||||
if (!resolver.updateDeclaration(*m_globalContext->currentSuper())) return false;
|
if (!resolver.updateDeclaration(*m_globalContext->currentSuper())) return false;
|
||||||
if (!resolver.resolveNamesAndTypes(*contract)) return false;
|
if (!resolver.resolveNamesAndTypes(*contract)) return false;
|
||||||
|
|
||||||
if (m_contracts.find(contract->fullyQualifiedName()) != m_contracts.end())
|
// 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
|
||||||
ContractDefinition const* existingContract = m_contracts[contract->fullyQualifiedName()].contract;
|
// already causes a double-declaration error elsewhere, so we do not report
|
||||||
if (contract != existingContract)
|
// an error here and instead silently drop any additional contracts we find.
|
||||||
{
|
|
||||||
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);
|
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
|
||||||
noErrors = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_contracts[contract->fullyQualifiedName()].contract = contract;
|
m_contracts[contract->fullyQualifiedName()].contract = contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,28 +209,12 @@ bool CompilerStack::parse()
|
|||||||
else
|
else
|
||||||
noErrors = false;
|
noErrors = false;
|
||||||
|
|
||||||
// Note that find() must be used here to prevent an automatic insert into the map
|
// Note that we now reference contracts by their fully qualified names, and
|
||||||
if (m_contracts.find(contract->fullyQualifiedName()) != m_contracts.end())
|
// 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
|
||||||
ContractDefinition const* existingContract = m_contracts[contract->fullyQualifiedName()].contract;
|
// an error here and instead silently drop any additional contracts we find.
|
||||||
|
|
||||||
if (contract != existingContract)
|
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
|
||||||
{
|
|
||||||
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
|
|
||||||
m_contracts[contract->fullyQualifiedName()].contract = contract;
|
m_contracts[contract->fullyQualifiedName()].contract = contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user