aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorRhett Aultman <roadriverrail@gmail.com>2016-12-20 20:57:46 +0800
committerRhett Aultman <rhett.aultman@meraki.net>2017-01-17 01:32:57 +0800
commit85c55c796adf4d93c3d11ccb8d048a51dc46cf8d (patch)
tree676fe9db8f0854cb5a4c7fe59a353b8cae33be7e /libsolidity
parentf8914c6b281f398d6084f10708233bf79d633ef0 (diff)
downloaddexon-solidity-85c55c796adf4d93c3d11ccb8d048a51dc46cf8d.tar.gz
dexon-solidity-85c55c796adf4d93c3d11ccb8d048a51dc46cf8d.tar.zst
dexon-solidity-85c55c796adf4d93c3d11ccb8d048a51dc46cf8d.zip
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.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/interface/CompilerStack.cpp49
1 files changed, 10 insertions, 39 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index fbaf1bcc..d4675a23 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -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;
-
- 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;
- }
+ // 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.
- }
- else
+ if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
m_contracts[contract->fullyQualifiedName()].contract = contract;
}