Is public state variable auto getter override upgrade safe?

Hey guys, I have a question:

Is is safe to add the override keyword to a state var and upgrade as such:

uint256 public override varName;

The override indicates that the auto generated getter implements an interface.

1 Like

Yes, I think it is ok, such as:

pragma solidity >=0.6.0 <0.9.0;

contract A
{
    function f() external view virtual returns(uint) { return 5; }
}

contract B is A
{
    uint public override f;
}

For more details, you can have a check the keyword override in the solidity document.

2 Likes

Hi @Mvii7,

Welcome to the community :wave:

I assume so, as you aren’t changing the type or order of the state variable.