Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-02

A Delphi "class constructor" does not compile in FPC

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

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
Sven Barth
to silvioprog
silvioprog wrote 45 lines
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?

Yes. Please report.

Regards,
Sven