[fpc-devel] Is that supposed to work: property with "[var index: TFoo]" ?
Ryan Joseph
genericptr at gmail.com
Fri Jun 28 20:12:06 CEST 2019
> On Jun 28, 2019, at 1:39 AM, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
>
> I just tested with Delphi and it works there as well. So contrary to what we thought this does not seem to be a bug...
I think it’s still buggy. Why does this compile? I guess it would make sense if the property didn’t have any parameters and just mapped to any of the overloaded functions but with the parameters it doesn’t make any sense.
I submitted my patch for multiple default properties (https://bugs.freepascal.org/view.php?id=35772) which is a more sane solution than allowing this:
program test;
type
tINIFile = object
private
function GetAsText( akey:integer):PAnsiChar; overload;
function GetAsText(ans,asection,akey:PAnsiChar):PAnsiChar; overload;
public
property Value [ans:PAnsiChar; asection:PAnsiChar; akey:PAnsiChar]:PAnsiChar
read GetAsText; default;
end;
function tINIFile.GetAsText( akey:integer):PAnsiChar;
begin
end;
function tINIFile.GetAsText(ans,asection,akey:PAnsiChar):PAnsiChar;
begin
end;
var
o: tINIFile;
s: PAnsiChar;
begin
s := o[1];
s := o['a','b','c'];
end.
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list