[Feature, patch] Introduce the AS/IS operator for arbitrary enumeration types
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
The following patch introduces the AS/IS operator for arbitrary enumeration types - a new built-in conversion from integer to enum with range check.
A test unit for FPC test suite is included as well.
Steps to reproduce:
type
TMyEnum = (zero, one, two);
var
E: TMyEnum;
begin
E := 1 as TMyEnum; // OK
E := -1 as TMyEnum; // error 219
end;
Additional information:
As discussed in fpc-mailing list:
http://lists.freepascal.org/pipermail/fpc-devel/2017-July/038029.html
http://lists.freepascal.org/pipermail/fpc-devel/2017-July/038030.html
Mantis conversion info:
- Mantis ID: 33603
- Version: 3.1.1
- Monitored by: » @martok (Martok), » Vincent (Vincent Snijders), » Akira1364 (Akira1364), » @CuriousKit (J. Gareth Moreton)