Record helper property doesn't respect read-only state
Original Reporter info from Mantis: ryan_joseph @genericptr
-
Reporter name: Ryan Joseph
Original Reporter info from Mantis: ryan_joseph @genericptr
- Reporter name: Ryan Joseph
Description:
When writing to the "point" property of TThing an error should be issued because the property is read-only, but due to the using a record helper property the read-only state is ignored and no error is issued.
Related bugs:
https://bugs.freepascal.org/view.php?id=23620
https://bugs.freepascal.org/view.php?id=14534
Steps to reproduce:
{$mode objfpc}
{$modeswitch advancedrecords}
program test;
type
TPoint = record
x, y: integer;
end;
type
TSizeHelper = record helper for TPoint
procedure SetWidth(newValue: integer); inline;
procedure SetHeight(newValue: integer); inline;
function GetWidth: integer; inline;
function GetHeight: integer; inline;
property Width: integer read GetWidth write SetWidth;
property Height: integer read GetHeight write SetHeight;
end;
procedure TSizeHelper.SetWidth(newValue: integer);
begin
x := newValue;
end;
procedure TSizeHelper.SetHeight(newValue: integer);
begin
y := newValue;
end;
function TSizeHelper.GetWidth: integer;
begin
result := x;
end;
function TSizeHelper.GetHeight: integer;
begin
result := y;
end;
type
TThing = record
m_point: TPoint;
function GetPoint: TPoint;
property point: TPoint read GetPoint;
end;
function TThing.GetPoint: TPoint;
begin
result := m_point;
end;
var
t: TThing;
begin
// should be an error because "point" is a read-only property
t.point.width := 0;
end.
Mantis conversion info:
- Mantis ID: 36768
- Version: 3.3.1