[fpc-devel] [Patch/RFC] Warnings for (in/over)complete case statements

Ondrej Pokorny lazarus at kluug.net
Sun May 19 17:53:01 CEST 2019


On 12.05.2019 16:36, Jonas Maebe wrote:
> Thanks. I have added these warnings to the compiler in r42047, and 
> also the static/dynamic errors for Standard resp. Extended ISO Pascal.
>
> By default, the warnings are enabled for
> * enums
> * boolean
> * integer subrange types that don't span the entire range of their 
> storage (e.g. 0..254, -128..0, ..., but not 
> shortint/byte/smallint/word/...)

I do like this new warning.

I just don't understand why (for the else-block) it is shown at the end 
of the first statement, just before the semicolon (see the | where the 
warning is shown):

program Project1;
type
   TMyEnum = (one, two);
   procedure A;
   begin
   end;
var
   E: TMyEnum;
   I: Integer;
begin
   case E of
     one: ;
     two: ;
   else
     I := 15|;
     A;
   end;
end.

IMO it would make much more sense if it was shown in front of or behind 
the else keyword:

|else
else|

Ondrej




More information about the fpc-devel mailing list