Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E121: Recursive type alias

This error occurs when type aliases reference each other in a cycle, creating an infinite recursion.

Example

TYPE type1 : type2; END_TYPE
TYPE type2 : type1; END_TYPE

In this example, type1 is defined as type2, which is in turn defined as type1, creating a circular dependency.

Another example

TYPE self_type : self_type; END_TYPE

This shows a type alias that directly references itself.

How to fix

Break the chain by resolving to concrete types

Break the circular dependency by ensuring that type aliases eventually resolve to concrete types:

TYPE typeA : DINT; END_TYPE      (* Points to concrete type *)
TYPE typeB : typeA; END_TYPE     (* Points to another alias, but ultimately resolves to DINT *)