I have encountered a potential concern regarding the use of the override keyword in the name
, symbol
, and decimals
functions of the ERC20
contract. According to best practices, the override
keyword should be used to ensure proper method overriding and prevent subtle bugs. However, I have noticed that these functions work both with and without the override keyword.
I would like clarification on whether the absence of the override
keyword in these functions could lead to any potential bugs or unexpected behavior during smart contract development. Below are the relevant code snippets for comparison:
function name() public view virtual returns (string memory) { ... }
// vs
function name() public view virtual override returns (string memory) { ... }
function symbol() public view virtual returns (string memory) { ... }
// vs
function symbol() public view virtual override returns (string memory) { ... }
function decimals() public view virtual returns (uint8) { ... }
// vs
function decimals() public view virtual override returns (uint8) { ... }
Environment:
I am using OpenZeppelin Contracts in my project.
I appreciate your insights and assistance on this matter.