General type restriction

This generic ad will not compile

type
  TFoo<T> = record
    Value : T;
  end;

  TFooo = TFoo<TFoo<Int64>>; // this is fine
  TFoooooInt64 = TFoo<TFoo<TFoo<Int64>>>; // E2564

due to

E2564 Undefined Type ' TFoo<T>'

This error E2564 is documented as

This happens when trying to define a type restriction on a generic type using it.

program E2564;

{$APPTYPE CONSOLE}
type
  TRec<T: record> = record
    A: T;
  end;

  TClass = record
    V: TRec<TClass>; //E2564
  end;

begin
end.

But this is not so.

Is this a bug or is this restriction documented?

+4
source share

Source: https://habr.com/ru/post/1606207/


All Articles