Disallow calling base constructors without arguments.

This commit is contained in:
chriseth 2018-06-29 00:06:51 +02:00 committed by Alex Beregszaszi
parent ef269bf40d
commit 7e5406dd89
3 changed files with 6 additions and 15 deletions

View File

@ -39,6 +39,7 @@ Breaking Changes:
* Type Checker: Disallow values for constants that are not compile-time constants. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow values for constants that are not compile-time constants. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow arithmetic operations for boolean variables. * Type Checker: Disallow arithmetic operations for boolean variables.
* Type Checker: Disallow tight packing of literals. This was already the case in the experimental 0.5.0 mode. * Type Checker: Disallow tight packing of literals. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow calling base constructors without parentheses. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size. * Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size.
* Type Checker: Disallow conversions between unrelated contract types. Explicit conversion via ``address`` can still achieve it. * Type Checker: Disallow conversions between unrelated contract types. Explicit conversion via ``address`` can still achieve it.
* Type Checker: Disallow empty tuple components. This was partly already the case in the experimental 0.5.0 mode. * Type Checker: Disallow empty tuple components. This was partly already the case in the experimental 0.5.0 mode.

View File

@ -279,8 +279,6 @@ void TypeChecker::checkContractAbstractFunctions(ContractDefinition const& _cont
void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const& _contract) void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const& _contract)
{ {
bool const v050 = _contract.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
vector<ContractDefinition const*> const& bases = _contract.annotation().linearizedBaseContracts; vector<ContractDefinition const*> const& bases = _contract.annotation().linearizedBaseContracts;
// Determine the arguments that are used for the base constructors. // Determine the arguments that are used for the base constructors.
@ -296,18 +294,10 @@ void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const
annotateBaseConstructorArguments(_contract, baseContract->constructor(), modifier.get()); annotateBaseConstructorArguments(_contract, baseContract->constructor(), modifier.get());
} }
else else
{ m_errorReporter.declarationError(
if (v050) modifier->location(),
m_errorReporter.declarationError( "Modifier-style base constructor call without arguments."
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()) for (ASTPointer<InheritanceSpecifier> const& base: contract->baseContracts())

View File

@ -1,4 +1,4 @@
contract A { constructor() public { } } contract A { constructor() public { } }
contract B is A { constructor() A public { } } contract B is A { constructor() A public { } }
// ---- // ----
// Warning: (72-73): Modifier-style base constructor call without arguments. // DeclarationError: (72-73): Modifier-style base constructor call without arguments.