On 02.07.2017 19:29, Martok wrote:
  - Case statements execute*precisely one*  of their branches: the statements of
the matching case label, or the else block otherwise

To support your argument, the current Delphi documentation says the same:

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Declarations_and_Statements

/Whichever caseList has a value equal to that of selectorExpression determines the statement to be used. If none of the caseLists has the same value as selectorExpression, then the statements in the else clause (if there is one) are executed./

According to Delphi documentation, invalid values should point to the else clause.

Furthermore, it is OK to use invalid values in caseList as well:

program Project1;

{$APPTYPE CONSOLE}

type
  TMyEnum = (one, two);

{$R+}
var
  E: TMyEnum;
begin
  E := TMyEnum(-1);
  case E of
    one, two: Writeln('valid');
    TMyEnum(-1): Writeln('minus one');
  else
    Writeln('invalid');
  end;
end.

The program above writes 'minus one' in Delphi.

Ondrej

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to