Detect multiple constructor definitions in the same contract (using new and old schemes).
contract A {
uint x;
constructor() public {
x = 0;
}
function A() public {
x = 1;
}
function test() public returns(uint) {
return x;
}
}
In Solidity 0.4.22, a contract with both constructor schemes will compile. The first constructor will take precedence over the second, which may be unintended.
Only declare one constructor, preferably using the new scheme constructor(...)
instead of function <contractName>(...)
.
multiple-constructors on Slither's wiki.