With pleasure :)

Yes it looks like if the parameter count matches, there is a compile error (correct). If it doesn't match (there are less or more parameters), it compiles (wrong).

Furthermore it doesn't only affect the getter but also the setter. All possible combinations compile. See attached project. I suspect the setter could be dangerous in connection to operator overloading.

Ondrej

program arraypropbug;

uses
  sysutils;

type
  TObj = class
  public
    function GetS(Index: Integer): string; overload;
    function GetS(Index1, Index2: Integer): Double; overload;
    procedure SetS(Index: Integer; const Str: string); overload;
    procedure SetS(Index: Integer; const Number: Double); overload;
    procedure SetS(Index1,  Index2: Integer; const Str: string); overload;
    procedure SetS(Index1,  Index2: Integer; const Number: Double); overload;
    property S[Index: Integer]: string read GetS write SetS;
  end;

{ TObj }

function TObj.GetS(Index1, Index2: Integer): Double;
begin
  Result := Index1 / Index2;
end;

function TObj.GetS(Index: Integer): string;
begin
  Result := IntToStr(Index);
end;

procedure TObj.SetS(Index1, Index2: Integer; const Number: Double);
begin

end;

procedure TObj.SetS(Index1, Index2: Integer; const Str: string);
begin

end;

procedure TObj.SetS(Index: Integer; const Number: Double);
begin

end;

procedure TObj.SetS(Index: Integer; const Str: string);
begin

end;

var
  o: TObj;
  s: string;
  d: Double;
begin
  o := TObj.Create;
  s := o.S[1];            // valid
  d := o.S[10, 3];        // !!!
  o.S[1] := 'string';     // valid
  o.S[1] := 11.9;         // !!!
  o.S[10, 3] := 'hello';  // !!!
  o.S[10, 3] := 15.4;     // !!!
end.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to