SA0013: Declarations with the same variable name
Function | Determines variables with the same name as other variables (example: global and local variables with the same name), or the same name as functions, actions, methods or properties within the same access range. |
Reason | Identical names can be confusing when the code is read and can lead to errors if the wrong object is accessed accidentally. We therefore recommend using naming conventions that avoid such situations. |
Importance | Medium |
PLCopen rule | N5/N9 |
Samples:
Global variable list GVL_App:
VAR_GLOBAL
nVar : INT;
END_VARMAIN program, containing a method with the name Sample:
PROGRAM MAIN
VAR
bVar : BOOL;
nVar : INT; // => SA0013
Sample : DWORD; // => SA0013
END_VAR.nVar := 100; // Writing global variable "nVar"
nVar := 500; // Writing local variable "nVar"METHOD Sample
VAR_INPUT
…