Why is a private type of a Class is visible through property of that class? lazarus / 21-General ---------------------------------------------------------------------- Valdas · 2023-06-09 10:13 Hello, in Unit2 is declared: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     TTest_class = class(TCustomControl)    private type        TChoise = (tcc__One, tcc__Two);  // <- private !!    private        FChoise: TChoise;        procedure Set__Choise(verte: TChoise);    public      property Choise: TChoise read FChoise write Set__Choise;    end;  Unit1 uses Unit2, and in Unit1 has a procedure: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  obj: TTest_class;begin    obj := TTest_class.Create(self);     obj.Choise := tcc__Two; // <- accessing private type     FreeAndNil(obj);end;  The Compiler does not issue any warnings and the project compiles fine. Public property makes private type public? ---------------------------------------------------------------------- TRon · 2023-06-09 10:27 That is called scoped enums (or lack thereof), see https://www.freepascal.org/docs-html/prog/progsu70.html ---------------------------------------------------------------------- Thaddy · 2023-06-09 13:25 make the private sections strict private? Although the documentation does not mention types, only methods and fields so you must assume that the type is always public. ---------------------------------------------------------------------- PascalDragon · 2023-06-09 20:30 Quote from: Valdas on June 09, 2023, 12:13:09 pmThe Compiler does not issue any warnings and the project compiles fine. As TRon remarked, by default the enum values are declared both locally and globally. In your example tcc__One is visible both as UnitName.tcc__One and UnitName.TTest.TChoise.tcc__One with the later only being usable inside of TTest_class (and - as it is not declared as strict private - inside the same unit). With the {$ScopedEnums On} directive you can disable the generation of the global symbol, which means that you must use TChoise.tcc__One then.