Rules / unreachable-branch
ELSIF branch never runs: the previous condition already covers the whole range
When an IF chain has x < T followed by ELSIF x >= T, the second branch takes the entire remaining range and every later ELSIF is dead. The compiler cannot see it because each condition is valid on its own.
Severity: Critical
Rule id: unreachable-branch
Unreachable IF/ELSIF branch
What the rule checks
IF x<T … ELSIF x>=T …: the second branch covers the whole remaining range, so the following ELSIF branches never execute (a classic weather-curve mistake).
What it does to the plant
Part of a heating curve or a control stage never applies: in deep frost the boiler holds the same setpoint as in a thaw.
Example
PROGRAM HeatCurveVAR rOutdoor : REAL; rSetpoint : REAL;END_VARIF rOutdoor < 0.0 THEN rSetpoint := 70.0;ELSIF rOutdoor >= 0.0 THEN rSetpoint := 60.0;ELSIF rOutdoor >= 10.0 THEN rSetpoint := 50.0;END_IF
PROGRAM HeatCurveVAR rOutdoor : REAL; rSetpoint : REAL;END_VARIF rOutdoor < 0.0 THEN rSetpoint := 70.0;ELSIF rOutdoor < 10.0 THEN rSetpoint := 60.0;ELSE rSetpoint := 50.0;END_IF
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
- Order the thresholds ascending with non-overlapping ranges:
IF x < T1 THEN … ELSIF x < T2 THEN … ELSE … - Replace the ELSIF chain with an array of curve points and interpolation.
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