[fpc-pascal] A Delphi "class constructor" does not compile in FPC

silvioprog silvioprog at gmail.com
Wed Feb 4 19:58:39 CET 2015


Hello,

First, please test the code below in Delphi and after in FPC:

  TTest = class
  public
    class constructor Create;
    constructor Create; virtual;
  end;
...
constructor TTest.Create;
begin
end;

class constructor TTest.Create;
begin
end;

OK, it will compile fine. Now test the code below in Delphi and after in
FPC (just changing the declaration order of the methods):

  TTest = class
  public
    constructor Create; virtual;
    class constructor Create;
  end;
...
constructor TTest.Create;
begin
end;

class constructor TTest.Create;
begin
end;

In Delphi it compile fine, but in FPC:

=======
Compile Project, Target: project1.exe: Exit code 1, Errors: 1, Warnings: 1
unit1.pas(23,23) Warning: An inherited method is hidden by "class
constructor Create;"
unit1.pas(39,25) Error: method identifier expected
=======

Bug?

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150204/0be8cd63/attachment.html>


More information about the fpc-pascal mailing list