Encapsulation protection is not enforced for generic records ( private members are visible )
## Summary When given a specialized generic record which has private members, those members are visible (assignable & readable) outside the record, and even outside the unit in which the record is declared. ## System Information FPC Version : 3.2.2-r0d122c49 [2024/01/26] for x86_64 Platform : Desktop Windows (11) (may affect other platforms) ## Steps to reproduce Compile the following example. ``` ---------------------------------------------- unit unitFault; {$mode delphiunicode}{$H+} interface type TRecord< T > = record private PrivateMember: string; end; implementation end. ---------------------------------------------- program protectionFault; {$mode delphiunicode}{$H+} uses unitFault; var X: TRecord< int32 >; // declared in unitFault begin X.PrivateMember := 'Should not be able to assign this.'; Writeln( X.PrivateMember ); Readln; end. ---------------------------------------------- ``` The above code should not compile, because 'PrivateMember' is private, and I would therefore expect the compiler to issue an "unknown identifier" error or similar. Note that if you remove the generics from the example, the code does not compile, demonstrating the expected behavior.
issue