SA0062: Expression is constant
Function | Determines the use of expressions that always have the same value at runtime. |
Reason | A complex expression that is calculated repeatedly and always generates the same value may indicate an error. This applies in particular if something else was intended. In any case, the expression causes an unnecessary load on the runtime. |
Importance | Medium |
Samples:
PROGRAM MAIN
VAR
bVar1 : BOOL;
bVar2 : BOOL;
nVar : INT;
END_VARIF MAX(nVar,1) >= 1 THEN // => SA0062
;
END_IF
bVar1 := bVar1 AND NOT TRUE; // => SA0062
bVar2 := bVar1 OR TRUE; // => SA0062
bVar2 := bVar1 OR NOT FALSE; // => SA0062
bVar2 := bVar1 AND FALSE; // => SA0062
IF (bVar1 = FALSE) THEN // => SA0062
;
END_IF
IF NOT bVar1 THEN // => no error
;
END_IF
nVar := 0;
IF nVar <> 0 THEN // => SA0062
;
END_IF