[Pas2js] Testing generics

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Oct 27 22:30:20 CET 2019


On 23.10.19 15:19, warleyalex via Pas2js wrote:
> class procedure issue in fpc mode.
>
> I would like this code:
> ---------------------------------------------
> type
>    generic TGen<T> = record
>      class procedure Proc(item: T); static;
>    end;
>
> generic class procedure TGen<T>.Proc(item: T);
> begin
>    //console.log(SizeOf(T));
>    if item > 0 then
>      WriteLn('Positive')
>    else if item < 0 then
>      WriteLn('Negative')
>    else
>      WriteLn('Zero');
> end;
> ---------------------------------------------
> begin
>    specialize TGen<LongInt>.Proc(0);       // Zero
>    specialize TGen<Int64>.Proc(123);       // Positive
>    specialize TGen<Extended>.Proc(-11);  // negative
> end;
>
> The compiler says: Error: class procedure expected, but procedure found

Fixed in trunk.

Mattias




More information about the Pas2js mailing list