diff options
author | chriseth <chris@ethereum.org> | 2018-06-29 06:06:51 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-01 19:28:27 +0800 |
commit | 7e5406dd8953cb819c397221fa55e6fa390108ee (patch) | |
tree | cf16b432bf0cc89f05a61b0d0fe6d2ba1e99af7f | |
parent | ef269bf40d3c6fc044c27654473353c556402b77 (diff) | |
download | dexon-solidity-7e5406dd8953cb819c397221fa55e6fa390108ee.tar.gz dexon-solidity-7e5406dd8953cb819c397221fa55e6fa390108ee.tar.zst dexon-solidity-7e5406dd8953cb819c397221fa55e6fa390108ee.zip |
Disallow calling base constructors without arguments.
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 18 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol | 2 |
3 files changed, 6 insertions, 15 deletions
diff --git a/Changelog.md b/Changelog.md index bcd55955..7f92a3de 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 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 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 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. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index d2fb9281..9e10b9b2 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -279,8 +279,6 @@ 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. @@ -296,18 +294,10 @@ void TypeChecker::checkContractBaseConstructorArguments(ContractDefinition const 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." - ); - } + m_errorReporter.declarationError( + modifier->location(), + "Modifier-style base constructor call without arguments." + ); } for (ASTPointer<InheritanceSpecifier> const& base: contract->baseContracts()) diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol index 6cf68d2a..8f5ceef8 100644 --- a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol @@ -1,4 +1,4 @@ contract A { constructor() 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. |