Skip to main content

SA0024: Untyped literals / constants

Identifies untyped literals which are part of an operation

Justification: Untyped literals are automatically typed according to their usage. In some cases, such as dw := ROL(DWORD#1, i);, this can lead to unexpected situations where it is better to use a typed literal in order to provide a unique clarification.

Importance: Low

Example 36. Example
PROGRAM PLC_PRG
VAR
    iTemp1 : INT := 10;  //no part of operation
    diTemp2 : DINT;
    liTemp3 : LINT;
    rTemp4 : REAL;
    lrTemp5 : LREAL;
 END_VAR
iTemp1 := iTemp1 + INT#34;
diTemp2 := diTemp2 + 23;   // SA0024
liTemp3 := liTemp3 + 124;  // SA0024
rTemp4 := rTemp4 + 1.1;    // SA0024
lrTemp5 := lrTemp5 + 3.4;  // SA0024

Output in the Messages view:

  • sa_icon_message.png SA0024: Untyped literal found