View Issue Details

IDProjectCategoryView StatusLast Update
0038329FPCCompilerpublic2021-02-27 22:13
Reporterrunewalsh Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version3.3.1 
Summary0038329: 'Class property' cannot map itself to the field of a 'class var' record
DescriptionCode below should probably compile, but does not, both with classes and advanced records, and the error message is clearly wrong.

Note that non-static properties were always allowed to map themselves to the fields of the non-static records, and static properties work with “top-level” static variables (Option1 in the example).
Steps To Reproduce{$mode objfpc}
type
    Thing = class
    class var
        opt1: cardinal;
        opts: record
            opt2: cardinal;
        end;

        class property Option1: cardinal read opt1;
        class property Option2: cardinal read opts.opt2;
    end;

begin
    Assert(Thing.Option1 = 0); // works
    Assert(Thing.Option2 = 0); // Error: Operator is not overloaded: "Thing.<record type>" = "ShortInt"
end.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

runewalsh

2021-02-27 20:19

reporter   ~0129210

Any thoughts on this extremely severe and important defect...

Serge Anvarov

2021-02-27 21:12

reporter   ~0129212

This is Delphi compatible. http://docwiki.embarcadero.com/RADStudio/Rio/en/E2459_Class_property_accessor_must_not_have_field_selector_(Delphi)

runewalsh

2021-02-27 22:00

reporter   ~0129214

Last edited: 2021-02-27 22:13

View 4 revisions

At least it should have a proper error message then.

But I don't see why this should be forbidden when instance properties are allowed to have field selectors. Not sure if it can be done easily, but if it can, allowing this won't really be incompatible, at least one-directionally. I believe FPC already has things allowed even in $MODE DELPHI that Delphi himself does not understand?

Issue History

Date Modified Username Field Change
2021-01-08 00:15 runewalsh New Issue
2021-02-27 20:19 runewalsh Note Added: 0129210
2021-02-27 21:12 Serge Anvarov Note Added: 0129212
2021-02-27 22:00 runewalsh Note Added: 0129214
2021-02-27 22:04 runewalsh Note Edited: 0129214 View Revisions
2021-02-27 22:05 runewalsh Note Edited: 0129214 View Revisions
2021-02-27 22:13 runewalsh Note Edited: 0129214 View Revisions