* a function can't be used to implicitely specialize a specialized procedure variable parameter and vice versa

+ added test
This commit is contained in:
Sven/Sarah Barth 2022-04-21 22:01:02 +02:00
parent a5f3040da5
commit c0fa45dc92
2 changed files with 26 additions and 0 deletions

View File

@ -945,6 +945,11 @@ uses
if target_proc.paras.count<>caller_proc.paras.count then
exit;
{ a mixture of functions and procedures is not allowed }
if (not assigned(target_proc.returndef) or is_void(target_proc.returndef)) xor
(not assigned(caller_proc.returndef) or is_void(caller_proc.returndef)) then
exit;
{ reject generics with constants }
for i:=0 to target_proc.genericdef.genericparas.count-1 do
if tsym(target_proc.genericdef.genericparas[i]).typ=constsym then

View File

@ -0,0 +1,21 @@
{ %FAIL }
program timpfuncspez37;
{$mode objfpc}
{$modeswitch implicitfunctionspecialization}
type
generic TTestFunc<T> = procedure(aArg1: T);
generic procedure DoTest<T>(aArg: specialize TTestFunc<T>);
begin
end;
function TestFunc(aArg1: LongInt): LongInt;
begin
end;
begin
DoTest(@TestFunc);
end.