mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4454 from ethereum/constructorArgCount
[BREAKING] Wrong argument count in constructor call
This commit is contained in:
commit
f3abfa81ad
@ -37,6 +37,7 @@ Breaking Changes:
|
||||
* Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size.
|
||||
* Type Checker: Disallow empty tuple components. This was partly already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Disallow specifying base constructor arguments multiple times in the same inheritance hierarchy. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Disallow calling constructor with wrong argument count. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Only accept a single ``bytes`` type for ``.call()`` (and family), ``keccak256()``, ``sha256()`` and ``ripemd160()``.
|
||||
* Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode.
|
||||
|
@ -548,20 +548,7 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
||||
|
||||
if (arguments)
|
||||
{
|
||||
bool v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
|
||||
|
||||
if (parameterTypes.size() != arguments->size())
|
||||
{
|
||||
if (arguments->size() == 0 && !v050)
|
||||
m_errorReporter.warning(
|
||||
_inheritance.location(),
|
||||
"Wrong argument count for constructor call: " +
|
||||
toString(arguments->size()) +
|
||||
" arguments given but expected " +
|
||||
toString(parameterTypes.size()) +
|
||||
"."
|
||||
);
|
||||
else
|
||||
{
|
||||
m_errorReporter.typeError(
|
||||
_inheritance.location(),
|
||||
@ -569,12 +556,10 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
||||
toString(arguments->size()) +
|
||||
" arguments given but expected " +
|
||||
toString(parameterTypes.size()) +
|
||||
"."
|
||||
". Remove parentheses if you do not want to provide arguments here."
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < arguments->size(); ++i)
|
||||
for (size_t i = 0; i < std::min(arguments->size(), parameterTypes.size()); ++i)
|
||||
if (!type(*(*arguments)[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
|
||||
m_errorReporter.typeError(
|
||||
(*arguments)[i]->location(),
|
||||
|
@ -4,4 +4,4 @@ contract Base {
|
||||
contract Derived is Base(2) { }
|
||||
contract Derived2 is Base(), Derived() { }
|
||||
// ----
|
||||
// Warning: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1.
|
||||
// TypeError: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1. Remove parentheses if you do not want to provide arguments here.
|
||||
|
@ -1,9 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
|
||||
contract Base {
|
||||
constructor(uint) public {}
|
||||
}
|
||||
contract Derived is Base(2) { }
|
||||
contract Derived2 is Base(), Derived() { }
|
||||
// ----
|
||||
// TypeError: (132-138): Wrong argument count for constructor call: 0 arguments given but expected 1.
|
@ -6,5 +6,5 @@ contract Derived2 is Base {
|
||||
constructor() Base(2) public { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2.
|
||||
// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2. Remove parentheses if you do not want to provide arguments here.
|
||||
// TypeError: (130-137): Wrong argument count for modifier invocation: 1 arguments given but expected 2.
|
||||
|
@ -1,4 +1,4 @@
|
||||
interface I {}
|
||||
contract C is I(2) {}
|
||||
// ----
|
||||
// TypeError: (29-33): Wrong argument count for constructor call: 1 arguments given but expected 0.
|
||||
// TypeError: (29-33): Wrong argument count for constructor call: 1 arguments given but expected 0. Remove parentheses if you do not want to provide arguments here.
|
||||
|
Loading…
Reference in New Issue
Block a user