Rules / case-without-else
CASE without ELSE in Structured Text: what happens on an unexpected value
If the selector takes a value that has no label, nothing runs and the program silently keeps its previous state. In state machines this is a common cause of a "stuck step".
Severity: Warning
Rule id: case-without-else
CASE without an ELSE branch (no default)
What the rule checks
CASE without an ELSE branch: if the selector takes a value not among the labels, nothing runs: a silent skip (a common state-machine bug).
What it does to the plant
A sequence gets stuck on a step that does not exist: equipment never leaves the mode and never reaches a safe state.
Example
PROGRAM SequenceVAR iStep : INT; xPump : BOOL;END_VARCASE iStep OF 0: xPump := FALSE; 1: xPump := TRUE;END_CASE
PROGRAM SequenceVAR iStep : INT; xPump : BOOL;END_VARCASE iStep OF 0: xPump := FALSE; 1: xPump := TRUE;ELSE xPump := FALSE; iStep := 0;END_CASE
Both listings are run through the linter by an automated test: the rule fires on the first and stays silent on the second.
How to fix
- Add an
ELSEbranch with default handling (signal/log/safe state). - If all selector values are truly covered, keep
ELSEwith an explanatory comment.
Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.
The same linter without uploading a file: command line and GitHub Action.
Related rules
2026-11-26