P2036

Code

P2036

Message

Nested REF_TO (multi-level indirection) is not supported

This error occurs when a REF_TO type declaration or a variable declaration references another REF_TO type, creating multi-level indirection. Nested references are not supported.

Example

The following code will generate error P2036:

TYPE
    IntRef : REF_TO INT;
    IntRefRef : REF_TO IntRef;  (* Error: nested REF_TO *)
END_TYPE

A variable declared as a reference to a reference type is the same nesting, and generates error P2036 too:

TYPE
    IntRef : REF_TO INT;
END_TYPE

PROGRAM Main
    VAR
        rr : REF_TO IntRef;  (* Error: nested REF_TO *)
    END_VAR
END_PROGRAM

To fix this error, use only a single level of indirection:

TYPE
    IntRef : REF_TO INT;  (* Correct: single level of REF_TO *)
END_TYPE

Think IronPLC is wrong about this?

If you believe this diagnostic is incorrect, open an issue on GitHub with a small sample that demonstrates the problem.