Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOL-006 Duplicated super-constructor calls not reported #3325

Closed
mvglasenapp opened this issue Dec 14, 2017 · 2 comments
Closed

SOL-006 Duplicated super-constructor calls not reported #3325

mvglasenapp opened this issue Dec 14, 2017 · 2 comments

Comments

@mvglasenapp
Copy link

mvglasenapp commented Dec 14, 2017

Description

Solidity has two methods to define super constructor calls: the first one is embedding the arguments in super contract definition and the second is by declaring a new constructor and adding the name and arguments for the super contract. If both methods are used concurrently, the constructor definition is used. However, the compiler does not warn the user that the first set of arguments has been overridden by the second.
The following example shows the problem. The parent constract is constructed with the
argument 40, not 20.

pragma solidity ^0.4.16;

contract P1 {
constructor P1(uint v) {}
}
contract P2 is​ ​P1(20)​ {
function P2(uint v)​ ​P1(40)​ {
}
}

Recommendations

Either prevent the user from defining two super-constructors or warn if one super-constructor overrides the other.

@chriseth
Copy link
Contributor

chriseth commented Mar 1, 2018

In addition to the above, conflicting super constructor arguments should also be an error in a multi-inheritance setting.

@chriseth chriseth moved this from To do to Ready to be worked on in 0.5.0 Mar 5, 2018
@chriseth chriseth added this to To do in 0.4.22 via automation Mar 8, 2018
@ekpyron ekpyron moved this from Ready to be worked on to In progress in 0.5.0 Mar 12, 2018
@ekpyron ekpyron self-assigned this Mar 12, 2018
@ekpyron ekpyron moved this from To do to In Progress in 0.4.22 Mar 12, 2018
@ekpyron ekpyron removed their assignment Mar 14, 2018
@ekpyron ekpyron moved this from In Progress to To do in 0.4.22 Mar 14, 2018
@ekpyron ekpyron moved this from In progress to Ready to be worked on in 0.5.0 Mar 14, 2018
@chriseth
Copy link
Contributor

Furthermore, if parentheses are given, the number of arguments has to match the number of parameters (currently, empty parentheses is the same as no parentheses).

@ekpyron ekpyron self-assigned this Apr 4, 2018
@ekpyron ekpyron moved this from To do to Under Review in 0.4.22 Apr 4, 2018
@ekpyron ekpyron moved this from Under Review to In Progress in 0.4.22 Apr 4, 2018
0.5.0 automation moved this from Ready to be worked on to Done Apr 10, 2018
0.4.22 automation moved this from In Progress to Done Apr 10, 2018
@axic axic added this to Done in Coinspect Audit Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
0.4.22
  
Done
0.5.0
  
Done
Development

No branches or pull requests

3 participants