[fpc-devel] overload and Error: Duplicate identifier "Foo"

Martin Frb lazarus at mfriebe.de
Sun Feb 9 16:17:16 CET 2014


project1.lpr(5,19) Error: Duplicate identifier "Foo"

Now the interesting part is that ONLY happens if the two procedures are 
part of a class AND the parmeter has the same name as the procedure.

If I declare 2 procedures like that outside a class, then there is no error.
Also there is no error,  if it is just one procedure in a class.


It also happens like that
     procedure aFoo(Foo:pointer);
     procedure bFoo(aFoo, Bar:pointer);

So that shows why there is a conflict, and what conflicts with what 
"bfoo" is already used in the class. Now that is correct.

But if fpc checks (correctly) that a param name has not yet been used in 
the current context (class), then why does it not detect
     procedure aFoo(aFoo:pointer);

the param aFoo should conflict with the procedure? It is also in the 
same context ?

Is this exception (from  being checked) intentional?


------
program project1;
type
   TSome = class
     procedure Foo(Foo:pointer); overload;
     procedure Foo(Foo, Bar:pointer); overload;
   end;

{ TSome }
procedure TSome.Foo(Foo: pointer);
begin end;
procedure TSome.Foo(Foo, Bar: pointer);
begin end;

begin
end.




More information about the fpc-devel mailing list