aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-04-10 17:22:26 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-04-10 18:09:34 +0800
commit3eedbc6a9c60888dd967d6673a34511947da4aa1 (patch)
tree0a6e356f44df3763acb57327b34ae621f80cf068 /libsolidity/analysis
parentb52614116e9c72d840b375b0bbb1c56a63df3680 (diff)
downloaddexon-solidity-3eedbc6a9c60888dd967d6673a34511947da4aa1.tar
dexon-solidity-3eedbc6a9c60888dd967d6673a34511947da4aa1.tar.gz
dexon-solidity-3eedbc6a9c60888dd967d6673a34511947da4aa1.tar.bz2
dexon-solidity-3eedbc6a9c60888dd967d6673a34511947da4aa1.tar.lz
dexon-solidity-3eedbc6a9c60888dd967d6673a34511947da4aa1.tar.xz
dexon-solidity-3eedbc6a9c60888dd967d6673a34511947da4aa1.tar.zst
dexon-solidity-3eedbc6a9c60888dd967d6673a34511947da4aa1.zip
Error when using no parentheses in modifier-style constructor calls.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 1d8fd82d..abe57778 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -293,6 +293,8 @@ void TypeChecker::checkContractAbstractFunctions(ContractDefinition const& _cont
void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const& _contract)
{
+ bool const v050 = _contract.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
+
vector<ContractDefinition const*> const& bases = _contract.annotation().linearizedBaseContracts;
// Determine the arguments that are used for the base constructors.
@@ -302,8 +304,24 @@ void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const
for (auto const& modifier: constructor->modifiers())
{
auto baseContract = dynamic_cast<ContractDefinition const*>(&dereference(*modifier->name()));
- if (baseContract && baseContract->constructor() && !modifier->arguments().empty())
- annotateBaseConstructorArguments(_contract, baseContract->constructor(), modifier.get());
+ if (modifier->arguments())
+ {
+ if (baseContract && baseContract->constructor())
+ annotateBaseConstructorArguments(_contract, baseContract->constructor(), modifier.get());
+ }
+ else
+ {
+ if (v050)
+ m_errorReporter.declarationError(
+ modifier->location(),
+ "Modifier-style base constructor call without arguments."
+ );
+ else
+ m_errorReporter.warning(
+ modifier->location(),
+ "Modifier-style base constructor call without arguments."
+ );
+ }
}
for (ASTPointer<InheritanceSpecifier> const& base: contract->baseContracts())
@@ -804,7 +822,8 @@ void TypeChecker::visitManually(
vector<ContractDefinition const*> const& _bases
)
{
- std::vector<ASTPointer<Expression>> const& arguments = _modifier.arguments();
+ std::vector<ASTPointer<Expression>> const& arguments =
+ _modifier.arguments() ? *_modifier.arguments() : std::vector<ASTPointer<Expression>>();
for (ASTPointer<Expression> const& argument: arguments)
argument->accept(*this);
_modifier.name()->accept(*this);
@@ -842,7 +861,7 @@ void TypeChecker::visitManually(
);
return;
}
- for (size_t i = 0; i < _modifier.arguments().size(); ++i)
+ for (size_t i = 0; i < arguments.size(); ++i)
if (!type(*arguments[i])->isImplicitlyConvertibleTo(*type(*(*parameters)[i])))
m_errorReporter.typeError(
arguments[i]->location(),