Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2016-04

mode Delphi, property overload, and svn 19564

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David Jenkins

I was trying to compile code with overloaded properties:

MyClass = class
   function GetX(idx: integer): integer;
   function GetX(idxStr: string): integer;
public
   property X[ id : integer] : integer read GetX;
   property X[ id : string] : integer read GetX;
end;

I got the 'duplicate X' error. I googled and found that previously this should compile with {$mode delphi} (a google hit from before 2011). However setting mode delphi resulted in the same error.

Digging around in the compiler code and the repository I found SVN rev 19564 which was responding to Mantis 20580. I verified that the lines removed from symtable.pas:tObjectSymtable.checkduplicate lines 1298 - 1301 seem to have been the same code that allowed overloaded properties in Delphi mode (I stuck them back in and I was able to compile my overloaded properties code).

So the question is:

Mantis 20580 & SVN 19564 are about duplicate symbols but not overloaded properties in particular. However overloaded properties in mode Delphi appear to have gone away with that change. Was this intentional? (I tried to find discussion on this and couldn't).

I guess the other question would be if I am right that overloaded properties in mode delphi don't work since that change.

This is not critical to my work just something I ran across and wanted to get some clarification. I saw several discussions that indicated that overloaded properties are not available for objfpc (and not intended to be available). But I couldn't find anything recent about whether it was still intended to be available for mode delphi.

Thanks
David Jenkins

Sven Barth
to David Jenkins
"David Jenkins" wrote
So the question is: Mantis 20580 & SVN 19564 are about duplicate symbols but not overloaded

properties in particular. However overloaded properties in mode Delphi appear to have gone away with that change. Was this intentional? (I tried to find discussion on this and couldn't).

I guess the other question would be if I am right that overloaded

properties in mode delphi don't work since that change.

Overloaded properties are a more specialized variant of duplicate symbols, so of course they aren't mentioned especially in a fix. If the code you posted doesn't work in Delphi then we definitely won't add code in our Delphi mode to make it working there again, because in that case it had been a bug in FPC that had been fixed. If this code works in Delphi however then it's a bug in FPC and you should report it on Mantis.

Regards,
Sven

Maciej Izak
to Sven Barth

2016-04-26 8:02 GMT+02:00 Sven Barth :

Show quoted text 9 lines
Overloaded properties are a more specialized variant of duplicate symbols, so of course they aren't mentioned especially in a fix. If the code you posted doesn't work in Delphi then we definitely won't add code in our Delphi mode to make it working there again, because in that case it had been a bug in FPC that had been fixed. If this code works in Delphi however then it's a bug in FPC and you should report it on Mantis.

In Delphi is possible to overload properties marked with default modifier. That is possible only for mentioned kind of properties - with index parameter/parameters.

Best regards, Maciej Izak
David Jenkins
to Sven Barth: properties in particular. However overloaded properties in mode Delphi appear to have…
Sven Barth wrote 12 lines
Overloaded properties are a more specialized variant of duplicate symbols, so of course they aren't mentioned especially in a fix. If the code you posted doesn't work in Delphi then we definitely won't add code in our Delphi mode to make it working there again, because in that case it had been a bug in FPC that had been fixed. If this code works in Delphi however then it's a bug in FPC and you should report it on Mantis. Regards, Sven

I entered a Mantis (#30088) for this including example code that does compile on Delphi - as Maciej pointed out Delphi only accepts this for default properties.

David Jenkins