View Issue Details

IDProjectCategoryView StatusLast Update
0037848FPCDocumentationpublic2020-10-01 13:38
ReporterSven Barth Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0037848: Chapter about Generic type specialization promotes (fixed) bug as a feature
DescriptionAt the end of chapter 8.3 Generic type specialization there is the following paragraph:

Remark As of version 3.0, it is possible to make a forward definition of a generic class. In prior versions the compiler would generate an error if a forward declaration of a class was later defined as a generic specialization. This means that the following is now possible:
{$mode objfpc}  
Type  
  TMyClass = Class;  
 
  // Other declarations  
 
  TMyClass = specialize TList<T>; 


This is wrong. This was a bug and it's no longer allowed in 3.2.0.
Tagsgenerics
Fixed in Revision1756.
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Michael Van Canneyt

2020-10-01 09:41

administrator   ~0126015

Eh, I'm confused....

So, to recap: forward declarations of generic classes is not allowed ?

Sven Barth

2020-10-01 13:20

manager   ~0126023

Last edited: 2020-10-01 13:21

View 3 revisions

The documentation shows a forward declaration of a specialization, not a generic and yes, those are not allowed.

The forward declaration of a generic would look like this:

type
  generic TTest<T> = class;

  generic TTest<T> = class(TObject)
  end;


However this is not yet supported in FPC (there is a bug report for that with a patch, but it's not good enough as I had found out when testing it).

Michael Van Canneyt

2020-10-01 13:38

administrator   ~0126024

Thank you for the clarification! Changed the remark to state that it is not allowed.

Issue History

Date Modified Username Field Change
2020-09-30 23:27 Sven Barth New Issue
2020-09-30 23:27 Sven Barth Status new => assigned
2020-09-30 23:27 Sven Barth Assigned To => Michael Van Canneyt
2020-10-01 09:41 Michael Van Canneyt Note Added: 0126015
2020-10-01 13:20 Sven Barth Note Added: 0126023
2020-10-01 13:20 Sven Barth Tag Attached: generics
2020-10-01 13:20 Sven Barth Note Edited: 0126023 View Revisions
2020-10-01 13:21 Sven Barth Note Edited: 0126023 View Revisions
2020-10-01 13:38 Michael Van Canneyt Status assigned => resolved
2020-10-01 13:38 Michael Van Canneyt Resolution open => fixed
2020-10-01 13:38 Michael Van Canneyt Fixed in Version => 3.3.1
2020-10-01 13:38 Michael Van Canneyt Fixed in Revision => 1756.
2020-10-01 13:38 Michael Van Canneyt FPCTarget => 3.2.2
2020-10-01 13:38 Michael Van Canneyt Note Added: 0126024