"Warning: Case statement does not handle all possible cases" does not handle non-sequential enums
Original Reporter info from Mantis: Hixie
-
Reporter name: Ian Hickson
Original Reporter info from Mantis: Hixie
- Reporter name: Ian Hickson
Description:
In the following program, the "Warning: Case statement does not handle all possible cases" message is emitted by the compiler, even though every value is listed in the case statement.
The problem occurs any time the enum is not sequential. For example, if b=2 in the type declaration, it works fine.
program main;
type
TTest = (a = 1, b = 3);
var
Foo: TTest = a;
begin
case (Foo) of
a: ;
b: ;
end;
end.
By the way, I love this warning in general. It found a bunch of bugs and made it possible to clean out a bunch of dead code. Thanks for adding it!
Mantis conversion info:
- Mantis ID: 36974
- Build: 3.3.1 [2020/04/22] for x86_64
- Monitored by: » @KaiBurghardt (Kai Burghardt)