SA0027: Multiple usage of name

Function

Determines multiple use of a variable name/identifier or object name (POU) within the scope of a project. The following cases are covered:

  • The name of an enumeration constant is identical to the name in another enumeration within the application or in an included library.
  • The name of a variable is identical to the name of another object in the application or in an included library.
  • The name of a variable is identical to the name of an enumeration constant in an enumeration in the application or in an included library.
  • The name of an object is identical to the name of another object in the application or in an included library.

Reason

Identical names can be confusing when reading the code. They can lead to errors if the wrong object is accessed inadvertently. Therefore, define and follow naming conventions in order to avoid such situations.

Exception

Enumerations declared with the 'qualified_only' attribute are exempt from SA0027 checking because their elements can only be accessed in a qualified manner.

Importance

Medium

Sample:

The following sample generates error/warning SA0027, since the library Tc2_Standard is referenced in the project, which provides the function block TON.

PROGRAM MAIN
VAR
    ton  : INT;                  // => SA0027
END_VAR