View Issue Details

IDProjectCategoryView StatusLast Update
0029056FPCCompilerpublic2021-03-07 08:13
ReporterNick Assigned To 
Status newResolutionopen 
Product Version3.0.0 
Summary0029056: class can't have two default properties with same name
DescriptionHave two default properties with same name. In Delphi xe2 it's ok.

Error: Duplicate identifier "Values"
Hint: Identifier already defined in CustomDataSetDataModel.pas at line 14
Error: Only one default property is allowed
Steps To Reproduce{$mode delphi}
unit Unit2;


  TDsRecord = class
    function GetValueByIdx(Index: Integer): Variant;
    function GetValueByName(const FieldName: string): Variant;
    procedure SetValueByIdx(Index: Integer; const Value: Variant);
    procedure SetValueByName(const FieldName: string; const Value: Variant);
    property Values[Index: Integer]: Variant read GetValueByIdx write SetValueByIdx; default;
    property Values[const FieldName: string]: Variant read GetValueByName write SetValueByName; default;


TagsNo tags attached.
Fixed in Revision
Attached Files


has duplicate 0030088 resolvedJonas Maebe Delphi allows for overloaded default properties. FPC gives 'Error: Duplicate identifier' 


Thaddy de Koning

2015-11-21 11:16

reporter   ~0087439

Last edited: 2015-11-21 11:20

View 4 revisions

Yes, confirmed this is currently (3.1.1-r32385) an incompatibility with Delphi.
In Delphi, you can have a default property *per signature* instead of just one per class.

From the docs:
"If a class has a default property, you can access that property with the abbreviation object[index], which is equivalent to[index]. For example, given the declaration above, StringArray.Strings[7] can be abbreviated to StringArray[7]. A class can have only one default property with a given signature (array parameter list), but it is possible to overload the default property. Changing or hiding the default property in descendent classes may lead to unexpected behavior, since the compiler always binds to properties statically. "

Thaddy de Koning

2015-11-22 10:08

reporter   ~0087477

Mind you, the subject header is wrong. This is ONLY about default properties and their signatures. Delphi doesn't accept more than one non-default property with the same name.

Sven Barth

2015-11-22 10:34

manager   ~0087478

I updated the title.


Issue History

Date Modified Username Field Change
2015-11-20 22:57 Nick New Issue
2015-11-21 11:16 Thaddy de Koning Note Added: 0087439
2015-11-21 11:18 Thaddy de Koning Note Edited: 0087439 View Revisions
2015-11-21 11:19 Thaddy de Koning Note Edited: 0087439 View Revisions
2015-11-21 11:20 Thaddy de Koning Note Edited: 0087439 View Revisions
2015-11-22 10:08 Thaddy de Koning Note Added: 0087477
2015-11-22 10:34 Sven Barth Summary class can't have two properties with same name => class can't have two default properties with same name
2015-11-22 10:34 Sven Barth Note Added: 0087478
2016-05-02 23:03 Jonas Maebe Relationship added has duplicate 0030088