Attention

IronPLC implements many parts of the IEC 61131-3 standard and is working toward full Structured Text support. Key features still missing include ranges, enum and I/O mapping.

P2032

Code

P2032

Message

Reference type mismatch in assignment

This error occurs when a reference assignment has incompatible types. The reference type and the target type must match exactly.

Example

The following code will generate error P2032:

PROGRAM Main
    VAR
        x : INT;
        y : REF_TO REAL;
    END_VAR

    y := REF(x);  (* Error: REF_TO REAL cannot hold reference to INT *)
END_PROGRAM

To fix this error, ensure the reference type matches the variable type:

PROGRAM Main
    VAR
        x : INT;
        y : REF_TO INT;
    END_VAR

    y := REF(x);  (* Correct: REF_TO INT matches INT variable *)
END_PROGRAM