[fpc-devel] Conflict between Class Method Name and Local Function Name

Andrew LESH leshaw at vo.lu
Fri Nov 23 16:00:27 CET 2007


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.
                                       



More information about the fpc-devel mailing list