[fpc-pascal] Two possible generics bugs
Ryan Joseph
genericptr at gmail.com
Sun Dec 1 21:45:38 CET 2019
> On Nov 30, 2019, at 12:58 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> This can't work. ClassType is of type TClass and TClass.Create calls TObject.Create, *not* the constructor of your list type, cause the constructor chain is not virtual.
>
> What you can do is this:
>
> === code begin ===
>
> generic function CopyList<T: TFPSList> (source: T): T;
> begin
> result := T.Create;
> result.Assign(source);
> end;
>
> var
> a, b: TNodeObjectList;
> begin
> a := TNodeObjectList.Create;
> b := specialize CopyList<TNodeObjectList>(a);
> end.
>
> === code end ===
Found yet another internal compiler error trying your code:
https://bugs.freepascal.org/view.php?id=36388
The previous day was another internal compiler error with inline functions in case you missed it. ;)
https://bugs.freepascal.org/view.php?id=36381
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list