View Issue Details

IDProjectCategoryView StatusLast Update
0028949FPCCompilerpublic2019-07-09 18:33
ReporterOndrej PokornyAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status confirmedResolutionopen 
Product Version3.1.1Product Buildtrunk 
Target VersionFixed in Version 
Summary0028949: Compiler does not check if array property parameters match
DescriptionWhen an array property is used in the code, the compiler does not check if the parameters match the property definition. Instead it directly searches an (overloaded) getter/setter function that matches the used parameters.

Both getters and setters are affected.
Steps To Reproducetype
  TObj = class
  public
    function GetS(Index: Integer): string; overload;
    function GetS(Index1, Index2: Integer): Double; overload;
    property S[Index: Integer]: string read GetS;
  end;

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

(Full project is attached.)
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Relationships

has duplicate 0035809 closedTomas Hajny Invalid array property parameters 

Activities

Ondrej Pokorny

2015-11-03 08:58

reporter  

arraypropbug.lpr (1,367 bytes)

rd0x

2019-07-01 14:34

reporter   ~0117024

Delphi Rio 10.3 also fails for
  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; // !!!

Serge Anvarov

2019-07-01 17:36

reporter   ~0117025

rd0x, also? No, Delphi reject this code, but FPC accept.

Awkward

2019-07-01 23:21

reporter   ~0117027

And i happy what FPC accepts that code. I even use same mechanic in 1-2 my units. I think, this is very cool FPC feature.

Serge Anvarov

2019-07-03 23:24

reporter   ~0117051

Almost like variables with the same name but different types within the same block. From the point of clarity of the code, a dubious possibility.

Sven Barth

2019-07-05 14:37

manager   ~0117080

@Awkward: this is a bug and *will* be fixed.

Awkward

2019-07-07 22:33

reporter   ~0117106

if this is bug, can it be fixed to keep same bility by proper way? i mean, can we keep overloaded properties?

Ryan Joseph

2019-07-09 18:33

reporter   ~0117126

Overloads are going to be supported properly when 35772 is applied.

Issue History

Date Modified Username Field Change
2015-11-03 08:58 Ondrej Pokorny New Issue
2015-11-03 08:58 Ondrej Pokorny File Added: arraypropbug.lpr
2019-07-01 14:34 rd0x Note Added: 0117024
2019-07-01 17:36 Serge Anvarov Note Added: 0117025
2019-07-01 23:21 Awkward Note Added: 0117027
2019-07-03 23:24 Serge Anvarov Note Added: 0117051
2019-07-05 14:37 Sven Barth Status new => confirmed
2019-07-05 14:37 Sven Barth FPCTarget => -
2019-07-05 14:37 Sven Barth Note Added: 0117080
2019-07-07 09:55 Tomas Hajny Relationship added has duplicate 0035809
2019-07-07 22:33 Awkward Note Added: 0117106
2019-07-09 18:33 Ryan Joseph Note Added: 0117126