SA0013: Declarations with the same variable namePermalink

Detects variables with names that are already used by other variables (for example, global and local variables with the same name). Also detects variables with names of functions, actions, methods, or properties which are used in the same access scope. Variables are also detected that are declared in a GVL in the “Devices” view or in the POUs pool. For this, however, the GVL of the “POUs” view have to be used in the application program.

Justification: The same names can be confusing when reading the code, and they can cause errors if the wrong object is accessed unintentionally. We recommend that you use naming conventions to avoid these situations.

PLCopen rule: N5 / N9

Importance: Medium

Example

VAR_GLOBAL
	xVar1 : BOOL;
	iVar3 : INT;
END_VAR

PROGRAM PLC_PRG
VAR
	xVar1 : BOOL;  // SA0013
	iVar3 : INT;   // SA0013
END_VAR

xVar1 := NOT GVL.xVar1;
iVar3 := iVar3 + INT#2;
iVar3 := GVL.iVar3;

--> SA0013: Declaration of 'iVar1' hides symbol 'GVL.iVar1
--> SA0013: Declaration of 'xVar3' hides symbol 'GVL.xVar3

Example

The function block ‎POU‎ has the action ‎ACT‎ and the method ‎METH‎.

FUNCTION_BLOCK POU 
VAR
	ACT : UINT;  // SA0013
	METH : BYTE; // SA0013
END_VAR

--> SA0013: Declaration of 'ACT' hides symbol 'POT.ACT'
--> SA0013: Declaration of 'METH' hides symbol 'POT.METH'