aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface
diff options
context:
space:
mode:
authorRhett Aultman <roadriverrail@gmail.com>2016-12-12 15:58:01 +0800
committerRhett Aultman <rhett.aultman@meraki.net>2017-01-17 01:32:57 +0800
commite3b0827721f114a371df57b7079205034683ed25 (patch)
tree3b836590826e1b1bf5aacdd1074de8f48f5b5a11 /libsolidity/interface
parent8f25bd54e35dba3fb632c2d209a86acaba63d33d (diff)
downloaddexon-solidity-e3b0827721f114a371df57b7079205034683ed25.tar.gz
dexon-solidity-e3b0827721f114a371df57b7079205034683ed25.tar.zst
dexon-solidity-e3b0827721f114a371df57b7079205034683ed25.zip
Push the error instead of throwing it
Throwing a CompilerError on multiple contract definition violates the expectations of the test suite, which thinks that compile() will return false if the code can't compile. This brings contract collision reporting in line with most of the other errors.
Diffstat (limited to 'libsolidity/interface')
-rw-r--r--libsolidity/interface/CompilerStack.cpp44
1 files changed, 34 insertions, 10 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 13cf7d6c..7626406c 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -186,13 +186,24 @@ bool CompilerStack::parse()
{
const ContractDefinition* existingContract = m_contracts.find(contract->fullyQualifiedName())->second.contract;
if (contract != existingContract)
- BOOST_THROW_EXCEPTION(CompilerError() <<
+ {
+ auto err = make_shared<Error>(Error::Type::DeclarationError);
+ *err <<
errinfo_sourceLocation(contract->location()) <<
- errinfo_comment(contract->name() + " is already defined.") <<
- errinfo_secondarySourceLocation(
- SecondarySourceLocation().append("Previous definition is here:", existingContract->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;
}
if (!checkLibraryNameClashes())
@@ -216,14 +227,27 @@ bool CompilerStack::parse()
if (m_contracts.find(contract->fullyQualifiedName()) != m_contracts.end())
{
const ContractDefinition* existingContract = m_contracts.find(contract->fullyQualifiedName())->second.contract;
+
if (contract != existingContract)
- BOOST_THROW_EXCEPTION(CompilerError() <<
+ {
+ auto err = make_shared<Error>(Error::Type::DeclarationError);
+ *err <<
errinfo_sourceLocation(contract->location()) <<
- errinfo_comment(contract->name() + " is already defined at "
- + *(existingContract->location().sourceName)));
- }
+ errinfo_comment(
+ "Contract/Library \"" + contract->name() + "\" declared twice "
+ ) <<
+ errinfo_secondarySourceLocation(SecondarySourceLocation().append(
+ "The other declaration is here:", existingContract->location()));
- m_contracts[contract->fullyQualifiedName()].contract = contract;
+ m_errors.push_back(err);
+ noErrors = false;
+ }
+
+ }
+ else
+ {
+ m_contracts[contract->fullyQualifiedName()].contract = contract;
+ }
}
if (noErrors)