[fpc-devel] Issue with class vars
Paul Ishenin
ip at kmiac.ru
Wed Oct 27 11:05:14 CEST 2010
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.
More information about the fpc-devel
mailing list