SA0025: Unqualified enumeration constants
Detects enumeration constants for which a qualified name does not prepend the enumeration
Justification: Qualified access makes the code more readable and easier to maintain. Without the forcing of 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 example below: "red"). This would result in ambiguous access to this piece of code.
In every case, we recommend to use only enumerations with the pragma {attribute 'qualified-only'}
.
Importance: Medium
TYPE COLOR : (red, green, blue); END_TYPE
PROGRAM PLC_PRG VAR myColor : COLOR; END_VAR
myColor := COLOR.red; // OK myColor := red; // SA0025
Output in the Messages view:
SA0025: Enumeration constant 'red' not qualified
For more information, see: