I was wondering if the solidity compiler automatically sets a state variable to immutable if it is never modified?


contract MyContract {
  uint256 myNumber;

  constructor(uint256 _myNumber){
    myNumber = _myNumber;

  // nowhere else in the contract does myNumber gets modified only read

My question is will the solidity compiler convert that state variable to immutable without me explicitly declaring it immutable?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.