[fpc-devel] Debug compiler

Ondrej Pokorny lazarus at kluug.net
Mon Nov 2 16:12:41 CET 2015


On 01.11.2015 21:03, Ondrej Pokorny wrote:
> You cannot assign an array property to a variable. It does not exist 
> without the index parameter.

OK, there is a bug in ppc that allows to use an array property with *any 
paramete**r(s)* (also no parameter). Delphi does not allow it.

Actually ppc doesn't check if *MyProp[Index]* matches the property 
declaration but if there is an (overloaded) function that matches the 
Index parameter. Therefore you can declare a parameterless function with 
property getter's name that returns the enumerator and it will be used 
in the for-in loop!

I still think that it is a ppc bug and it would be better to have a 
clean way to do that. But if you don't like to extend the compiler, 
please don't fix this bug either.

It was still a good practice for me to play with the compiler. I 
wouldn't have found the bug without studying the compiler code. You can 
find demo code that shows how to create an array property enumerator in 
the issue report: http://bugs.freepascal.org/view.php?id=28820#c87065

Sven Barth & Michael Van Canneyt: you also showed an interest. What is 
your opinion about it?

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20151102/e959ff08/attachment.html>


More information about the fpc-devel mailing list