View Issue Details

IDProjectCategoryView StatusLast Update
0035012FPCDocumentationpublic2019-02-16 10:57
ReporterAkira1364Assigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSWindowsOS Version10
Product Version3.3.1Product BuildTrunk 
Target Version3.2.0Fixed in Version3.3.1 
Summary0035012: Section 8.5.5 of the reference guide, "Scope considerations" regarding generic type declarations, is simply incorrect.
DescriptionIt says that only {$mode Delphi} allows use of specializaions that have not been explicitly declared with type aliases. However, that is not true. The following example compiles and works:

program Test;

{$mode ObjFPC}
{$modeswitch AdvancedRecords}

type
  generic TTest<T> = record
    Value: T;
    class function Create(const AT: T): TTest; static; inline;
  end;

  class function TTest.Create(const AT: T): TTest;
  begin
    Result.Value := AT;
  end;

var T: specialize TTest<LongInt>;

begin
  T := specialize TTest<LongInt>.Create(1);
  WriteLn(T.Value);
end.
Steps To ReproduceNone relevant as it is documentation.
TagsNo tags attached.
Fixed in Revision1559
FPCOldBugId
FPCTarget
Attached Files

Activities

Michael Van Canneyt

2019-02-16 10:57

administrator   ~0114174

This limitation existed in the initial version of generics, and has indeed been removed, but the docs were never adapted.

Thanks for pointing it out.

Issue History

Date Modified Username Field Change
2019-02-05 15:56 Akira1364 New Issue
2019-02-05 15:56 Akira1364 Status new => assigned
2019-02-05 15:56 Akira1364 Assigned To => Michael Van Canneyt
2019-02-16 10:57 Michael Van Canneyt Fixed in Revision => 1559
2019-02-16 10:57 Michael Van Canneyt Note Added: 0114174
2019-02-16 10:57 Michael Van Canneyt Status assigned => resolved
2019-02-16 10:57 Michael Van Canneyt Fixed in Version => 3.3.1
2019-02-16 10:57 Michael Van Canneyt Resolution open => fixed
2019-02-16 10:57 Michael Van Canneyt Target Version => 3.2.0