[fpc-pascal] Error: Argument cannot be assigned to

Juha Manninen juha.manninen62 at gmail.com
Sun Jun 4 15:04:48 CEST 2023


Why the following code fails to compile?

type
  TMyRec = record
    ss: String;
    ii: Integer;
  end;
  TMyClass = class
  private
    fName: String;
    fRecInstance: TMyRec;
  property
    RecInstance: TMyRec read fRecInstance;// write fRecInstance;
  end;
var
  MyObj : TMyClass;
begin
  MyObj := TMyClass.Create;
  MyObj.RecInstance.ii := 123;
  MyObj.Free;
end.

Access through property seems to be the problem. Accessing fRecInstance
directly works.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230604/84ddcdb9/attachment.htm>


More information about the fpc-pascal mailing list