View Issue Details

IDProjectCategoryView StatusLast Update
0038642FPCCompilerpublic2021-03-27 11:24
ReporterAlfred Assigned ToSven Barth  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Fixed in Version3.3.1 
Summary0038642: Generics stumble upon non-sequential enums.
DescriptionWhen using a non-sequential enum together with generics, an [compiler] error is generated.

program projectenum;
{$mode delphi}{$H+}
uses
  classes,
  generics.collections;
type
  TMonthType = (January, February, May=10, June, July);
  TMonthList = TList<TMonthType>;
var
  myList : TMonthList;
begin
end.

Results in:
generics.defaults.pas(1051,43) Error: No type info available for this type

If "=10" is removed, all is well.
Additional InformationSee:
https://forum.lazarus.freepascal.org/index.php/topic,53763.msg398264
https://forum.lazarus.freepascal.org/index.php/topic,41736.msg398268.html#msg398268
Tagsgenerics
Fixed in Revision49064
FPCOldBugId
FPCTarget-
Attached Files

Activities

Florian

2021-03-20 09:41

administrator   ~0129770

Does this work in Delphi?

Michael Van Canneyt

2021-03-20 09:42

administrator   ~0129771

As far as I know it is normal that this does not work. GetEnumName etc. also do not work for enumerated types with assigned values.

Alfred

2021-03-20 09:46

reporter   ~0129772

Yes, this compiles (and works) in Delphi.

program Project11;
{$APPTYPE CONSOLE}
{$R *.res}
uses
  classes,
  generics.collections;
type
  TMonthType = (January, February, May=10, June, July);
  TMonthList = TList<TMonthType>;
var
  myList : TMonthList;
begin
end.

Alfred

2021-03-20 09:51

reporter   ~0129773

In fact, this also seems to work in FPC.
See the forum messages.
The ported ZXing works (after compiling twice). The port is made of original (Delphi) sources, but de-ARC-ed by using interfaces.

Anton Kavalenka

2021-03-20 11:54

reporter   ~0129779

AFAIK - no RTTI is generated for non-sequential or started from -1 enums.

Sven Barth

2021-03-27 09:37

manager   ~0129919

Turns out that in Delphi TypeInfo() returns Nil if used on a generic parameter that is a enum with holes instead of leading to a compile error....

Please test and close if okay.

Alfred

2021-03-27 11:24

reporter   ~0129920

Tested.
Example compiles.
ZXing compiles in one step without errors and runs as expected.

Thanks for the quick fix.

Issue History

Date Modified Username Field Change
2021-03-20 09:20 Alfred New Issue
2021-03-20 09:41 Florian Note Added: 0129770
2021-03-20 09:42 Michael Van Canneyt Note Added: 0129771
2021-03-20 09:46 Alfred Note Added: 0129772
2021-03-20 09:51 Alfred Note Added: 0129773
2021-03-20 11:54 Anton Kavalenka Note Added: 0129779
2021-03-26 20:03 Sven Barth Tag Attached: generics
2021-03-26 20:03 Sven Barth Assigned To => Sven Barth
2021-03-26 20:03 Sven Barth Status new => assigned
2021-03-27 09:37 Sven Barth Status assigned => resolved
2021-03-27 09:37 Sven Barth Resolution open => fixed
2021-03-27 09:37 Sven Barth Fixed in Version => 3.3.1
2021-03-27 09:37 Sven Barth Fixed in Revision => 49064
2021-03-27 09:37 Sven Barth FPCTarget => -
2021-03-27 09:37 Sven Barth Note Added: 0129919
2021-03-27 11:24 Alfred Status resolved => closed
2021-03-27 11:24 Alfred Note Added: 0129920