Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2022-12

Local Type T and generics

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vojtěch Čihák

Hi,
 
I have local type TTempItem, i.e. declared inside method of a generic class. When I write:
type 
     TTempItem = record
       Item: T;
       Empty: Boolean;
     end;
I got: Identifier not found "T".
 
When I write:
type
     TTempItem = record
       Item: TBaseGList.T;  //name of the class        Empty: Boolean;
     end;
I got: Generics without  specialization cannot be used as a type for a variable  
And finally
type TLocalT = T;
     TTempItem = record
       Item: TLocalT;
       Empty: Boolean;
     end;  
^^^ this works.
 
type TLocalT = TBaseGList.T;
     TTempItem = record
       Item: TLocalT;
       Empty: Boolean;
     end;  
^^^ work too.
 
Is this intended? Or known bug?
 
Thanks.
 
V.

Sven Barth
to Vojtěch Čihák
Vojtěch Čihák wrote 35 lines
Hi, I have local type TTempItem, i.e. declared inside method of a generic class. When I write: type      TTempItem = record        Item: T;        Empty: Boolean;      end; I got: Identifier not found "T". When I write: type      TTempItem = record        Item: TBaseGList.T;  //name of the class        Empty: Boolean;      end; I got: Generics without  specialization cannot be used as a type for a variable And finally type TLocalT = T;      TTempItem = record        Item: TLocalT;        Empty: Boolean;      end; ^^^ this works. type TLocalT = TBaseGList.T;      TTempItem = record        Item: TLocalT;        Empty: Boolean;      end; ^^^ work too. Is this intended? Or known bug?

It's a bug. Please report with a full example.

Regards,
Sven

Vojtěch Čihák
to Sven Barth

OK, done: https://gitlab.com/freepascal.org/fpc/source/-/issues/40085  
Thanks
______________________________________________________________

Show quoted text 5 lines
Od: "Sven Barth via fpc-pascal" Komu: "FPC-Pascal users discussions" Datum: 03.01.2023 22:29 Předmět: Re: [fpc-pascal] Local Type T and generics
Vojtěch Čihák wrote
Is this intended? Or known bug?

It's a bug. Please report with a full example.

Regards,
Sven