[fpc-pascal] FPC's behavior regarding new TObject methods

Sven Barth pascaldragon at googlemail.com
Sat Nov 13 14:19:57 CET 2010


Hello together!

I've installed FPC 2.4.2 and after reading the page about the changes 
since 2.4.0, I've compiled Lazarus and noticed a warning in imglist.pp 
regarding a Equals method (already reported). Now I remembered that 
http://wiki.freepascal.org/User_Changes_2.4.2#TObject_class_declaration 
mentions that FPC warns in mode delphi, but generates an error in mode 
objfpc. So I looked at the top of the unit, but did found "{$mode objfpc}".

Puzzled, I wrote the following test program:

==== source begin ====

program tobjectmethods;

{$mode objfpc}

type
   TTestObject = class
   public
     function ToString: String;
     function Equals(aObject: TObject): Boolean;
   end;

function TTestObject.ToString: String;
begin
   Result := 'FooBar';
end;

function TTestObject.Equals(aObject: TObject): Boolean;
begin
   Result := aObject.ToString = Self.ToString;
end;

begin

end.

==== source end ====

Compiling it with FPC 2.4.2 (and 2.5.1 as well) results only in warnings 
regarding the methods Equals and ToString and not errors as expected 
after reading the wiki.

So who is right?
a) the wiki (thus there is a bug in FPC - very bad, because 2.4.2 is 
already released)
b) the compiler (thus the wiki is wrong)

Regards,
Sven



More information about the fpc-pascal mailing list