[lazarus] Bug in compiler ??

Marc Weustink weus at quicknet.nl
Sun Mar 19 13:42:16 EST 2000


Or is it as designed ? (I hope not)

AFAIK is the following the same:

   //- 1 ----------
     M.X;
     M.Y;
   //- 2 ----------
     with M do
     begin
       X;
       Y;
     end;
   //--------------

However if X and Y are private or protected, you can access them in the 
second form, the first results in a compiler error (as I expected):

marc:~/fpc/lazarus/examples$ ppc386 test3
Target OS: Linux for i386
Compiling test3.pp
test3.pp(13,6) Error: Cannot access a private field of an object here
test3.pp(13,6) Warning: Variable M does not seem to be initialized
test3.pp(14,6) Error: Cannot access a protected field of an object here
test3.pp(22,4) Fatal: There were 2 errors compiling module, stopping

Marc


// ---- test3.pp ----------------------

program test3;

//{$mode objfpc}
{$mode delphi}

uses test3a;

var
   M: TMyObject;

begin
   M.X;
   M.Y;

   with M do
   begin
     X;
     Y;
   end;

end.

// ---- test3a.pp ----------------------

unit test3a;

//{$mode objfpc}
{$mode delphi}

interface

type
   TMyObject = class
   private
     procedure X;
   protected
     procedure Y;
   public
   end;

implementation

procedure TMyObject.X;
begin
end;

procedure TMyObject.Y;
begin
end;

end.






More information about the Lazarus mailing list