1

I get this compilation warning for the following contract:

pragma solidity ^0.4.24;

contract TestCalls {

    uint public lastMsgDataLength;
    uint public lastMsgValue;

    modifier setMsgFields {
        lastMsgDataLength = msg.data.length;
        lastMsgValue = msg.value;
        _;
    }

    constructor() setMsgFields public {
    }
}

I think that the compiler somehow misinterprets the modifier call as a base-constructor call.

Of course, there is no base constructor here, since the contract does not inherit anything.

How can I resolve this compilation warning?

P.S.: This code is taken directly from Gnosis GitHub Repository.

I have updated it from ^0.4.15 to ^0.4.24, so perhaps this is the source of the problem.

Thank you!

1

This warning will disappear if you add () to your modifier like this

  constructor() setMsgFields() public {
    }
  • When a modifier doesn't take any input arguments, I call it like this (i.e., without parenthesis). In fact, even in the contract that I asked this question about, the setMsgFields modifier is used like this (i.e., without parenthesis) in every other function. So this warning is restricted to the constructor alone??? – goodvibration Jul 16 '18 at 11:36
  • yes only for constructor have a look at the reason behind github.com/ethereum/solidity/pull/3853 – Badr Bellaj Jul 16 '18 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.