[fpc-devel] Issue with class vars

Birger Jansen birger at cnoc.nl
Wed Oct 27 11:10:44 CEST 2010


You are right, the notation confused me.
Thanks for clearing it out for me with a quick reply!

Kind regards,
  Birger

-----Oorspronkelijk bericht-----
Van: Paul Ishenin <ip at kmiac.ru>
Verzonden: wo 27-10-2010 11:05
Aan: FPC developers' list <fpc-devel at lists.freepascal.org>; 
Onderwerp: Re: [fpc-devel] Issue with class vars

> 27.10.2010 16:46, Birger Jansen wrote:
> 
> > When swapping the rows with class var and FMyField it becomes this:
> >
> >    TTest = class(TObject)
> >    private
> >      class var MyClassVar: Integer;
> >      FMyField: string;
> >    published
> >      property MyProperty: string read FMyField write FMyField;
> >    end;
> >
> > This breaks the code, but on a strange line: the line property MyProperty 
> (...) with Error: Illegal symbol for property access.
> 
> Compiler absolutely correctly reports you that MyProperty can't use 
> FMyField field because it is a class field in this case, not an instance 
> field.
> 
> The next code will work again:
> 
>      TTest = class(TObject)
>      private
>        class var
>          MyClassVar: Integer;
>        var
>          FMyField: string;
>      published
>        property MyProperty: string read FMyField write FMyField;
>      end;
> 
> Best regards,
> Paul Ishenin.
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>



More information about the fpc-devel mailing list