UPDATE: The issue is not about Enum but self defining of state variables:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
contract Test {
address public yolo = yolo;
}
The above compiles.
[OLD VERSION]
Enum values can be implicitly assigned & converted to state variables if named in the same way as the Enum entry.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
contract Enum {
enum SomeEnum { yolo }
// Only works if I call the variable the same as the `Enum` value.
address private yolo = yolo;
function enumTest() external view returns (address) {
return yolo;
}
}
I don't think this should compile. You can test it with other types, and it will work in the same way.
Environment
Compiler version: 0.8.25
Target EVM version (as per compiler settings): shangai
Framework/IDE (e.g. Truffle or Remix): chisel or remix
Description
UPDATE: The issue is not about
Enum
but self defining of state variables:The above compiles.
[OLD VERSION]
Enum
values can be implicitly assigned & converted to state variables if named in the same way as theEnum
entry.I don't think this should compile. You can test it with other types, and it will work in the same way.
Environment
0.8.25
shangai
chisel
orremix
Linux