[Lazarus] Overloading with generic type as parmeter causes compiler error.

Donald R. Ziesig donald at ziesig.org
Tue May 1 17:29:42 CEST 2012


  Hi Sven!

According to Lazarus (0.9.30.4) Help|About, fpc is version 2.6.0.

I will try with a recent trunk version (if I can figure out how to do it 
:-[ ) and let you know the results.

Thanks,

Don Z.

On 5/1/2012 5:21 AM, Sven Barth wrote:
> On 30.04.2012 17:45, Donald R. Ziesig wrote:
>> Hi All!
>>
>> I am working on a generic type library and ran into a problem at compile
>> time.
>>
>> type
>> generic TMyType<T> = class
>> *
>> *
>> *
>> function IndexOf( Item : T ) : Integer; overload;
>> functionIndexOf( aName : String) : Integer; overload;
>>
>> // generics1.pas Error: Function is already declared Public\Forward
>> "TMyType.IndexOf(AnsiString):LongInt;"
>>
>> // or, reverse the declarations:
>>
>> function IndexOf( aName : String ) : Integer; overload;
>> function IndexOf( Item : T ) : Integer; overload;
>>
>> // generics1.pas Error: Function is already declared Public\Forward
>> "TMyType.IndexOf(<undefined type>):LongInt;"
>>
>> end;
>>
>> Similar errors occur in implementation of the overloaded subprograms, as
>> in:
>>
>> // generics1.pas Error: function header "IndexOf" doesn't match forward
>> : var name changes aName => Item
>>
>>
>> The obvious work-around is to avoid overloading with generic types as
>> parameters, but that is really a hack in this case.
>>
>> Keep up the GREAT work,
>
> What version of FPC did you try with? If it was 2.6.0 or 2.6.1 or 
> anything older then please try with a recent trunk version. I fixed 
> this problem some weeks ago.
> If you already tested with a recent trunk version of FPC than please 
> open a bug report for the compiler with a simple example that does not 
> depend on the LCL and should compile.
>
> Regards,
> Sven
>
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>





More information about the Lazarus mailing list