View Issue Details

IDProjectCategoryView StatusLast Update
0033890FPCDocumentationpublic2018-06-28 10:33
ReporterThaddy de KoningAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformallOSallOS Versionall
Product Version3.0.4Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0033890: The documentation for generics in Delphi mode has a wrong example in section "8.5.2 Record type restrictions"
DescriptionThe documentation is written in two modes at the same time, which is confusing since you can not mix objfpc mode syntax with delphi mode syntax.



"In Delphi mode, the record type restrictions will also allow the use of simple types:

Type
generic TList<_T : record> = class(TObject)
  public
    Type TCompareFunc = function(const Item1, Item2: _T): Integer;
  Public
    data : _T;
    procedure Add(item: _T);
    procedure Sort(compare: TCompareFunc);
 end;
 
TIntList = TList<Integer>;"
Additional InformationThere are two ways to solve this:
1) use mode delphi for the whole example:
Type
  TList<_T : record> = class(TObject)
  public
    Type TCompareFunc = function(const Item1, Item2: _T): Integer;
  Public
    data : _T;
    procedure Add(item: _T);
    procedure Sort(compare: TCompareFunc);
 end;
 
2) Document that the generic type is declared in another unit from the subsequent specialized type and document that a subsequent use in delphi mode changes the expected behavior: a specialized type such as this example in mode Delphi accepts simple types even if the declaration in mode objfpc will prevent that and even if the type limitation to a record type is in a unit written in objfpc mode.

3) or both (maybe lengthy...)
TagsNo tags attached.
Fixed in Revision1488
FPCOldBugId
FPCTarget
Attached Files

Activities

Thaddy de Koning

2018-06-22 12:46

reporter   ~0108998

Note ad 2: the opposite is also true: when a unit is written in mode Delphi, with the record limitation then when it is used in mode objfpc specifying a simple type doesn't work.

Michael Van Canneyt

2018-06-28 10:33

administrator   ~0109099

Fixed, added an example. Thanks for reporting!

Issue History

Date Modified Username Field Change
2018-06-22 10:44 Thaddy de Koning New Issue
2018-06-22 10:44 Thaddy de Koning Status new => assigned
2018-06-22 10:44 Thaddy de Koning Assigned To => Michael Van Canneyt
2018-06-22 12:46 Thaddy de Koning Note Added: 0108998
2018-06-28 10:33 Michael Van Canneyt Fixed in Revision => 1488
2018-06-28 10:33 Michael Van Canneyt Note Added: 0109099
2018-06-28 10:33 Michael Van Canneyt Status assigned => resolved
2018-06-28 10:33 Michael Van Canneyt Fixed in Version => 3.1.1
2018-06-28 10:33 Michael Van Canneyt Resolution open => fixed
2018-06-28 10:33 Michael Van Canneyt Target Version => 3.2.0