diff options
author | chriseth <chris@ethereum.org> | 2018-04-10 17:39:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-10 17:39:31 +0800 |
commit | b52614116e9c72d840b375b0bbb1c56a63df3680 (patch) | |
tree | f60709e1daf118eb20598598b2497270e4ffa299 /docs | |
parent | 27385d6dedca067f0e234f0301c2bb0e914cff15 (diff) | |
parent | 549ba801fb2a175cfb24e3c83b63030f47984e95 (diff) | |
download | dexon-solidity-b52614116e9c72d840b375b0bbb1c56a63df3680.tar.gz dexon-solidity-b52614116e9c72d840b375b0bbb1c56a63df3680.tar.zst dexon-solidity-b52614116e9c72d840b375b0bbb1c56a63df3680.zip |
Merge pull request #3821 from ethereum/warn-constructor-override
Warn constructor override
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index f8a44fb3..0dd9845c 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -1034,9 +1034,12 @@ the base constructors. This can be done in two ways:: constructor(uint _x) public { x = _x; } } - contract Derived is Base(7) { - constructor(uint _y) Base(_y * _y) public { - } + contract Derived1 is Base(7) { + constructor(uint _y) public {} + } + + contract Derived2 is Base { + constructor(uint _y) Base(_y * _y) public {} } One way is directly in the inheritance list (``is Base(7)``). The other is in @@ -1046,8 +1049,9 @@ do it is more convenient if the constructor argument is a constant and defines the behaviour of the contract or describes it. The second way has to be used if the constructor arguments of the base depend on those of the -derived contract. If, as in this silly example, both places -are used, the modifier-style argument takes precedence. +derived contract. Arguments have to be given either in the +inheritance list or in modifier-style in the derived constuctor. +Specifying arguments in both places is an error. .. index:: ! inheritance;multiple, ! linearization, ! C3 linearization |