generic procedure; forward / with both const and type constraints does not work.

FPC 3.3.1 9d6b66c9

According to https://forum.lazarus.freepascal.org/index.php/topic,52157.msg383991.html#msg383991

  • constraints MUST NOT be repeated in the implementation. They only occur in the forward
  • "const constraints" are different, and must be repeated

If each type of constraint occurs on its own then that works (2 working examples at the end).

But if they are mixed then it fails. The below fails:

program Project1;{$Mode objfpc}

generic procedure Foo<const A: integer;B: TObject;C>(p1: B); forward; //project1.lpr(3,19) Error: Forward declaration not solved "Foo$3(A);"

generic procedure Foo<const A: integer; B; C>(p1: B);
begin {} end;

begin
end.

However, the following work

generic procedure Foo<const A: integer;B;C>(p1: B); forward;

generic procedure Foo<const A: integer; B; C>(p1: B);
begin {} end;
generic procedure Foo<A;B: TObject;C>(p1: B); forward;

generic procedure Foo<A; B; C>(p1: B);
begin {} end;
Edited by Martin