Sign in Join

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

Mailing lists / fpc-pascal / 2006-03

scope error? duplicate identifier property and parameter

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Dale Welch

I am getting an error compiling with fpc 2.1.1 under lazarus with duplicate identifier that seems to be a scope error. Under lazarus all you have to do is add any dataset and add an onposterror event handler.
it doesn't like that "Action" is both a property of an object and a parameter of a procedure in that object. Action is defined as a published property in form. then it is also defined as ...

    property Action: TBasicAction read GetAction write SetAction;
    published property Action;
    procedure MemDataset1EditError(DataSet: TDataSet; E: EDatabaseError;   var Action: TDataAction);
    procedure MemDataset1PostError(DataSet: TDataSet; E: EDatabaseError;  var Action: TDataAction);

----------
Free Pascal Compiler version 2.1.1 [2006/02/22] for i386 Copyright (c) 1993-2005 by Florian Klaempfl
Target OS: Linux for i386
Compiling dbgridtest.lpr
Compiling unit1.pas
unit1.pas(37,78) Error: Duplicate identifier "Action" unit1.pas(37,78) Hint: Identifier already defined in unit FORMS at line 567 unit1.pas(39,11) Error: Duplicate identifier "Action" unit1.pas(39,11) Hint: Identifier already defined in unit FORMS at line 567 unit1.pas(52,1) Fatal: There were 2 errors compiling module, stopping ----------

Reply by email

L505
to Dale Welch
I am getting an error compiling with fpc 2.1.1 under lazarus with duplicate

identifier

that seems to be a scope error. Under lazarus all you have to do is add any dataset and add an onposterror event handler. it doesn't like that "Action" is both a property of an object and a parameter

of a procedure in that object.

Show quoted text 5 lines
Action is defined as a published property in form. then it is also defined as ... property Action: TBasicAction read GetAction write SetAction; published property Action; procedure MemDataset1EditError(DataSet: TDataSet; E: EDatabaseError; var
Action: TDataAction);
procedure MemDataset1PostError(DataSet: TDataSet; E: EDatabaseError; var
Action: TDataAction);

I think I've come across this before, it is in OBJFPC mode. AFAIK the solution is usually to use something like

  procedure MemDataset1EditError(DataSet: TDataSet; E: EDatabaseError;   var
AAction: TDataAction);
  procedure MemDataset1PostError(DataSet: TDataSet; E: EDatabaseError;  var
AAction: TDataAction);
  procedure Something(AYourParam: string; ASomeOther: integer);

'A' prefix for temporary stuff that could conflic with more permanent stuff such as properties.

You know, it is really clearer this way because who says you are not referencing Action property? How do you know?
This way, you are sure. OBJFPC mode is more obvious/strict.

Reply by email