P4095

Code

P4095

Message

Keyword used as a name requires choosing a dialect or –allow-keywords-as-names flag

This error occurs when one of the keywords ON, STEP, R_EDGE or F_EDGE names a variable or an enumeration member (e.g. TYPE M : (Off, On); END_TYPE) without the --allow-keywords-as-names compiler flag.

IEC 61131-3 reserves its keywords: a keyword is not to be used for any other purpose, such as a variable name. ON belongs to a resource declaration (RESOURCE r ON PLC), STEP to sequential function charts, and R_EDGE and F_EDGE to edge-detecting inputs. Other toolchains do not reserve these four, so programs written for them often use them as names.

A name that only contains one of the keywords, such as OnState or StepCount, is an ordinary identifier and is always allowed.

Example

The following code will generate error P4095:

TYPE
    M : (Off, On);
END_TYPE

To fix this error, choose a name that is not a keyword:

TYPE
    M : (Off, Running);
END_TYPE

Or enable the extension:

Pass the --allow-keywords-as-names flag to enable it, or select a dialect that includes it. See Enabling Dialects and Features for the dialects and flags reference.

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.