[fpc-devel] class property - should this work - static field in nested field

Martin Frb lazarus at mfriebe.de
Wed May 15 17:05:55 CEST 2024


The below fails to compile.

However "b" is a class var. The fact that it is reached via a normal 
field, does not change that. The address/value of TBar.f.b can be known 
without on instance of TBar required.

Mind, this is a theoretical question, I don't actually need it, just 
came across the idea and wanted to know.


program Project1;
type

   TFoo = object
     a: integer;
     class var b: integer;
   end;

   TBar = class
     f: TFoo;
     class property fb: integer read f.b;   // Error: Illegal symbol for 
property access
   end;

begin
end.



More information about the fpc-devel mailing list