View Issue Details

IDProjectCategoryView StatusLast Update
0030088FPCCompilerpublic2021-03-07 08:14
ReporterDavid Jenkins Assigned ToJonas Maebe  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionduplicate 
PlatformOSX/LinuxOSOSX/Liinux 
Product Version3.0.0 
Summary0030088: Delphi allows for overloaded default properties. FPC gives 'Error: Duplicate identifier'
DescriptionFollowing code compiles with Delphi fails with FPC

type
   AClass = class
    function GetStr(ANdx: Integer): string; overload;
    function GetStr(AStr: String): string; overload;
  public
    property MyStr[ANdx: Integer]: string read GetStr; default;
    property MyStr[AStr: string]: string read GetStr; default;
  end;
Steps To Reproducecompile following:

program Project1;

{$mode objfpc}{$H+}

uses
    {$IFDEF UNIX}{$IFDEF UseCThreads}
    cthreads,
    {$ENDIF}{$ENDIF}
    Classes
    { you can add units after this };

type
   AClass = class
    function GetStr(ANdx: Integer): string; overload;
    function GetStr(AStr: String): string; overload;
  public
    property MyStr[ANdx: Integer]: string read GetStr; default;
    property MyStr[AStr: string]: string read GetStr; default;
  end;

function AClass.GetStr(ANdx: Integer): string;
begin
  Result := 'str1';
end;

function AClass.GetStr(AStr: String): string;
begin
  Result := 'str2';
end;

begin
end.
                       
Additional InformationI believe that this worked in the past but code changes in SVN 19564 removed duplicate identifiers for a related issue and also removed duplicate properties.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

duplicate of 0029056 new class can't have two default properties with same name 

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2016-05-02 22:53 David Jenkins New Issue
2016-05-02 23:03 Jonas Maebe Relationship added duplicate of 0029056
2016-05-02 23:03 Jonas Maebe Status new => resolved
2016-05-02 23:03 Jonas Maebe Resolution open => duplicate
2016-05-02 23:03 Jonas Maebe Assigned To => Jonas Maebe