Hello,

I have noticed, that this construct fails in current trunk version:

unit a;
type generic TFoo<T> = record
  privat FField: integer;
end;

unit b;
type TBar = specialize TFoo<Bar>;
type TBarHelper = type helper for TBar
  procedure DoSomething;
end;

procedure TBarHelper.DoSomething;
begin
  FField := 0;   // <-- access to `private` field forbidden due to different 
unit
end;

So, in the specialized record, private fields are no longer accessible. This 
used to work some time ago (about 1 year). I do fully understand that it is 
forbidden, because it's the way "private" is meant to be.

However, I'd like to ask whether this behavior change is intentional or a 
regression. If it's intentional, we need `protected` fields in records, too, 
imho. Otherwise, there'd be no way to access a private field in a specialized 
type if it has been defined in the generic type. And there may be good reasons 
not to make it public.

Kind regards,
Thomas

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to