[fpc-devel] Impossible CONST generic constraints in forward declarations...?
Martin Frb
lazarus at mfriebe.de
Tue Nov 25 22:02:13 CET 2025
On 25/11/2025 20:41, Martin Frb via fpc-devel wrote:
> According to
> https://forum.lazarus.freepascal.org/index.php/topic,52157.msg383991.html#msg383991
>
>
> 2) Constraints in a "forward" declaration in the implementation (or a
> program?) must be kept.
Actually, that does not seem to be true either...
The below only compiles when they are NOT kept (same if converted to
mode delphi)
unit Unit1;{$mode ObjFPC}
interface
implementation
generic procedure Foo3<A: TObject;B>(p1: A); forward;
generic procedure Foo3<A; B>(p1: A); begin end;
end.
However,
in a program, they must be dropped.
(it will not compile, if the :TObject is kept)
program Project1;
generic procedure Foo3<A: TObject;B>(p1: A); forward;
generic procedure Foo3<A; B>(p1: A);
begin end;
begin end.
--------------
More, it seems that many checks are performed only on the FIRST gen param.
Changes in the rest of them seems to be ignored, at least sometimes...
More information about the fpc-devel
mailing list