[fpc-pascal] scope error? duplicate identifier property andparameter

L505 fpc505 at z505.com
Sun Mar 12 19:17:18 CET 2006


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




More information about the fpc-pascal mailing list