[fpc-pascal] Generics question

Sven Barth pascaldragon at googlemail.com
Mon Dec 3 08:00:51 CET 2018


Am So., 2. Dez. 2018, 23:29 hat Bart <bartjunk64 at gmail.com> geschrieben:

> Hi,
>
>   { TFoo }
>
>   generic TFoo<T> = class
>     procedure Bar;
>   end;
>
> { TFoo }
>
> procedure TFoo.Bar;
>   procedure localproc;
>   begin end;
> begin
> end;
>
> This will not compile (fpc 3.0.4):
> gentest.lpr(35,4) Error: Generic methods cannot have nested procedures
>
> While the message is clear, the reason for this is not (to me at last).
>
> Does anybody know why?
>

Because Delphi does not allow that either. We relaxed that however in 3.1.1
and it should be part of 3.2.0. You can test the corresponding branch of
you want.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181203/0cd6d249/attachment.html>


More information about the fpc-pascal mailing list