View Issue Details

IDProjectCategoryView StatusLast Update
0029056FPCCompilerpublic2021-03-07 08:13
ReporterNick Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platformx86OSWindows 
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;

interface

type
  TDsRecord = class
  private
    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);
  public
    property Values[Index: Integer]: Variant read GetValueByIdx write SetValueByIdx; default;
    property Values[const FieldName: string]: Variant read GetValueByName write SetValueByName; default;
  end;

implementation

end.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

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

Activities

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 object.property[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. "

http://docwiki.embarcadero.com/RADStudio/XE8/en/Properties

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.

Regards,
Sven

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