[fpc-pascal] Enum property can't be published

Pierre Muller pierre at freepascal.org
Tue Sep 27 12:19:49 CEST 2022



Le 27/09/2022 à 11:22, Hairy Pixels via fpc-pascal a écrit :
> 
> 
>> On Sep 27, 2022, at 4:17 PM, Marco van de Voort via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>>
>> 3.2.2 compiles without warnings,  3.3.1 (i386-win32 from 17 sept:)
>>
>> ptt.pp(14,44) Warning: This property will not be published
>>
>> Possibly enums with assigned values (which can have gaps) are not safe to publish, and this was only now noted?
> 
> I must have missed that.
> 
> What’s a good solution here? It looks like the code needs these enums to be 1 indexed, otherwise they are all in order with no gaps. If I could publish those and just do a +1 first that would work.

   Wouldn't adding NoError in front of the enum work for this case?
You don't need the explicit values, and their would not change!


   TDiagnosticSeverity = ( NoError { will be 0},
			  Error {will stay equal to 1},
                           Warning {will stay equal to 2},
                           Information  {will stay equal to 3},
                           Hint {will stay equal to 4}
                           );


Not a general solution, but a very simple one in that specific case!

Pierre


More information about the fpc-pascal mailing list