[fpc-devel] [] property overloads

Ondrej Pokorny lazarus at kluug.net
Mon Jul 1 20:44:21 CEST 2019


On 01.07.2019 19:38, Michael Van Canneyt wrote:
> On Mon, 1 Jul 2019, Ondrej Pokorny wrote:
>> On 01.07.2019 18:21, Michael Van Canneyt wrote:
>>> On Mon, 1 Jul 2019, Ondrej Pokorny wrote:
>>>> On 01.07.2019 15:57, Ryan Joseph wrote:
>>>>   TTest = class
>>>>   public
>>>>     // ...
>>>>     property StringArray[Index: Integer]: string read GetString;
>>>>     property StringArray: TTestObjectEnumerator read GetString;
>>>>   end;
>> From the above example "Mytest.StringArray" can only evaluate to 
>> TTestObjectEnumerator. Nothing else.
>
> Well, this is IMHO not correct. The array is also a possibility.
>
> The compiler encounters Mytest.StringArray - at that point he has 2
> possibilities. It's an array (and an index must expected) or it is an
> enumerator (and nothing must be expected), but at this point the compiler
> cannot decide without looking at the context.

There is no array. "property StringArray[Index: Integer]" is not an 
array and cannot be evaluated as an array.

If the compiler encounters "Mytest.StringArray" it can be evaluated only 
as the non-indexed overload.

Ondrej



More information about the fpc-devel mailing list