scope error? duplicate identifier property and parameter

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

scope error? duplicate identifier property and parameter

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
----------

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: scope error? duplicate identifier property andparameter

L505

> 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);



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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal