Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

P2005

Code

P2005

Message

Recursive enumeration for type

This error occurs when there is a recursive enumeration definition, where an enumeration type references itself either directly or indirectly.

Example

The following code will generate error P2005:

TYPE
    RecursiveEnum : RecursiveEnum;  (* Error: Enumeration references itself *)
END_TYPE

The enumeration RecursiveEnum references itself in its own definition, creating a recursive cycle.

Another example of indirect recursion:

TYPE
    EnumA : EnumB;
    EnumB : EnumA;  (* Error: Indirect recursive enumeration *)
END_TYPE

To fix this error, define the enumeration with actual values instead of self-references:

TYPE
    StatusEnum : (IDLE, RUNNING, STOPPED, ERROR) := IDLE;  (* Correct: Proper enumeration *)
END_TYPE

Or use a base type for type aliases:

TYPE
    BaseEnum : (VALUE1, VALUE2, VALUE3) := VALUE1;
    AliasEnum : BaseEnum;  (* Correct: References a proper enumeration *)
END_TYPE