View Issue Details

IDProjectCategoryView StatusLast Update
0038058FPCCompilerpublic2020-11-15 19:24
ReporterAndrey Zubarev Assigned ToFlorian  
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0038058: For-in loop for sets inside generics
Descriptionprogram Project1;

  TElems=set of TElem;//Output set, need convert my_a->a, my_c->c, my_e->e остальное скипаем
  TmyElems=set of TmyElem;//Input set

  generic TSetConverter<TGEnumIn,TGSetIn,TGEnumOut,TGSetOut,TGEnumConverter>=class
    class function Convert(value:TGSetIn):TGSetOut;

    class function Convert(valueIn:TmyElem;out valueOut:TElem):boolean;

  TConverter=specialize TSetConverter<TmyElem,TmyElems,TElem,TElems,TmyElem2TElem_Converter>;

  class function TmyElem2TElem_Converter.Convert(valueIn:TmyElem;out valueOut:TElem):boolean;
    case valueIn of
      else result:=false;

  {//Variant 1
  class function TSetConverter.Convert(value:TGSetIn):TGSetOut;
    for CurrentEnumIn:=low(TGEnumIn) to high(TGEnumIn) do begin
      if tvalue<>value then begin
        if TGEnumConverter.convert(CurrentEnumIn,CurrentEnumOut) then
        if tvalue=[] then exit;
  //Variant 2
  class function TSetConverter.Convert(value:TGSetIn):TGSetOut;
    for CurrentEnumIn in value do
        if TGEnumConverter.convert(CurrentEnumIn,CurrentEnumOut) then

  for Elem in Elems do

variant 1 work, variant 2 not work
It by design? or not implement and for-in must be work in generics
TagsNo tags attached.
Fixed in Revision47425
Attached Files


Andrey Zubarev

2020-11-15 19:24

reporter   ~0126975


Issue History

Date Modified Username Field Change
2020-11-10 04:31 Andrey Zubarev New Issue
2020-11-15 19:13 Florian Assigned To => Florian
2020-11-15 19:13 Florian Status new => resolved
2020-11-15 19:13 Florian Resolution open => fixed
2020-11-15 19:13 Florian Fixed in Version => 3.3.1
2020-11-15 19:13 Florian Fixed in Revision => 47425
2020-11-15 19:13 Florian FPCTarget => -
2020-11-15 19:24 Andrey Zubarev Status resolved => closed
2020-11-15 19:24 Andrey Zubarev Note Added: 0126975