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

Sven Barth pascaldragon at googlemail.com
Sun Feb 9 17:27:12 CET 2014


On 09.02.2014 16:17, Martin Frb wrote:
> 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?

The checks against duplicate identifiers are sadly not as strict as one 
might wish... :( (especially since the introduction of nested types) 
What you encountered here is just another example.

Regards,
Sven




More information about the fpc-devel mailing list