SA0025: Unqualified enumeration constants
Function | Determines enumeration constants that are not used with a qualified name, i.e. without preceding enumeration name. |
Reason | Qualified access makes the code more readable and easier to maintain. Without forcing qualified variable names, an additional enumeration could be inserted when the program is extended. This enumeration contains a constant with the same name as an existing enumeration (see the sample below: "eRed"). In this case there would be an ambiguous access in this piece of code. We recommend using only enumerations that have the {attribute 'qualified-only’}. |
Importance | Medium |
Sample:
Enumeration E_Color:
TYPE E_Color :
(
eRed,
eGreen,
eBlue
);
END_TYPEMAIN program:
PROGRAM MAIN
VAR
eColor : E_Color;
END_VAReColor := E_Color.eGreen; // no error
eColor := eGreen; // => SA0025