[fpc-pascal] Property write access on records

Ryan Joseph genericptr at gmail.com
Mon Mar 2 05:41:49 CET 2020


In the snippet below why isn't it an error to write to a field of the read-only property? I was hoping this would give me some type safety but it just writes to a temp variable and does nothing. Not very helpful if you ask me.


=========================

type
  TSheet = record
      m_tableSize: TVec2i;
      function GetTableSize: TVec2i;
      property TableSize: TVec2i read GetTableSize;
  end;

var
  sheet: TSheet;
begin
  // why isn't this an error?
  sheet.x := 1;
end;

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list