Slither

Slither

Community Analyzer

Multiple constructor schemes SLITHER-W1006

Anti-pattern
Critical

Detect multiple constructor definitions in the same contract (using new and old schemes).

Exploit Scenario

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.

Recommendation

Only declare one constructor, preferably using the new scheme constructor(...) instead of function <contractName>(...).

Learn more

multiple-constructors on Slither's wiki.