Sign in Join

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

Mailing lists / fpc-devel / 2007-11

Conflict between Class Method Name and Local Function Name

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Andrew LESH

Since upgrading to Lazarus 0.9.24 which uses FPC 2.2.0, there seems to be a change in behaviour which is not listed in
http://www.freepascal.org/mantis/changelog_page.php.

If a Local Function is declared within a Method of a Class and it has the same name as another Method of the Class, the syntax error 'Duplicate Identifier "<name>" is flagged.

In the example below, the Procedure Display is declared local to GoButtonClick, but is flagged with the syntax error 'Duplicate Identifier "Display" because the Class contains a method called Display, even though they are in different scopes.

Is this an intended change to the Compiler ?

unit TestXPMain;
{$mode Delphi}{$H+}
interface

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,

  StdCtrls, Buttons;
type
  { TForm1 }
  TForm1 = class(TForm)
   BottomPanel: TPanel;
   GoButton: TButton;
   Memo: TMemo;
   TopPanel: TPanel;
   procedure GoButtonClick(Sender: TObject);
  private
    { private declarations }
  public
    PROCEDURE Display(Const Text : String);
  end;
var
  Form1: TForm1;
implementation

{ TForm1 }

procedure TForm1.GoButtonClick(Sender: TObject);
  PROCEDURE Display(Const Text : string);
  begin
  End;
begin
  Display('Start');
end;
procedure TForm1.Display(const Text: String);
begin
  Memo.Lines.Add(Text);
end;
initialization
  {$I TestXPMain.lrs}
end.

Reply by email