[fpc-pascal] Two possible generics bugs
Sven Barth
pascaldragon at googlemail.com
Fri Nov 29 00:38:36 CET 2019
Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Do., 28. Nov. 2019, 20:36:
> Testing on 3.3.1. Are these both bugs? I wanted to ask first before filing
> a report.
>
> {$mode objfpc}
>
> program test;
> uses
> FGL;
>
> // No Error specializing TFPGList in parameter list...
> generic function CopyList<T>(source: specialize TFPGList<T>): specialize
> TFPGList<T>;
> begin
> end;
>
> // ... but getting an error specializing TFPGObjectList in parameter list
> // Class type expected, but got "T"
> generic function CopyList<T>(source: specialize TFPGObjectList<T>):
> specialize TFPGObjectList<T>;
> begin
> end;
>
> begin
> end.
>
TFPGObjectList has a constraint to class types, so you need to constrain
your T as well using ": class".
Please note however that you'll likely encounter another bug then once you
move your function to a unit: https://bugs.freepascal.org/view.php?id=35943
> ===========================
>
> {$mode objfpc}
>
> program test;
> uses
> FGL;
>
> // Type identifier expected
> // Internal error 2019112401
> generic function CopyList<T>(source: specialize FGL.TFPGObjectList<T>):
> specialize FGL.TFPGObjectList<T>;
> begin
> end;
>
> begin
> end.
>
The "specialize" is part of the generic identifier, so it must be
"FGL.specialize TFPGObjectList<T>".
That said however an internal error should not happen (especially the one I
just added some days ago ^^'). Please report this one.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20191129/d8e2faa0/attachment.html>
More information about the fpc-pascal
mailing list