Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-10

Issue with class vars

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Birger Jansen

Hi,

I encountered a possible bug (or at least a compiler error that should be clearified) when using class vars in FPC 2.4.3:

This class definition will compile:

  TTest = class(TObject)
  private
    FMyField: string;
    class var MyClassVar: Integer;
  published
    property MyProperty: string read FMyField write FMyField;
  end;

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.

Shall I report a bug for this?

Kind regards,
Birger Jansen

Reply by email

Birger Jansen
to Birger Jansen

The problem is with trunk instead of 2.4.3!

Sorry for the confusion.

-----Oorspronkelijk bericht-----
Van: Birger Jansen
Verzonden: wo 27-10-2010 10:47
Aan: ;
Onderwerp: [fpc-devel] Issue with class vars

Show quoted text 36 lines
Hi, I encountered a possible bug (or at least a compiler error that should be clearified) when using class vars in FPC 2.4.3: This class definition will compile: TTest = class(TObject) private FMyField: string; class var MyClassVar: Integer; published property MyProperty: string read FMyField write FMyField; end; 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. Shall I report a bug for this? Kind regards, Birger Jansen _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Paul Ishenin
to Birger Jansen: I encountered a possible bug (or at least a compiler error that should be clearified)…
Birger Jansen wrote 11 lines
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.

Reply by email

Birger Jansen
to Paul Ishenin

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
Verzonden: wo 27-10-2010 11:05
Aan: FPC developers' list ;
Onderwerp: Re: [fpc-devel] Issue with class vars

Show quoted text 38 lines
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 - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email