P2002¶
- Code
P2002
- Message
Subrange declaration minimum value is not less than the maximum
This error occurs when a subrange type declaration has a minimum value that is not strictly less than the maximum value.
A subrange type narrows an integer type to the values between its bounds, so a subrange of one value or none is not a useful type. This check applies only to subrange types. An array index range may have equal bounds, because ARRAY[0..0] is an ordinary array of one element; an inverted array index range is reported as P2024.
Example¶
The following code will generate error P2002:
TYPE
InvalidRange : INT(10..-10); (* Error: minimum (10) >= maximum (-10) *)
SingleValue : INT(5..5); (* Error: minimum (5) >= maximum (5) *)
END_TYPE
The subrange declarations have a minimum value that is not strictly less than the maximum value.
To fix this error, ensure the minimum value is less than the maximum value:
TYPE
ValidRange : INT(-10..10); (* Correct: minimum (-10) < maximum (10) *)
END_TYPE
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.