* fix #39857: don't trash symbols marked as vo_is_internal

+ added test
This commit is contained in:
Sven/Sarah Barth 2022-08-26 17:42:22 +02:00
parent 8595c927a8
commit 5135b586cb
2 changed files with 32 additions and 1 deletions

View File

@ -788,7 +788,7 @@ implementation
(vo_is_funcret in tabstractnormalvarsym(p).varoptions)
)
) and
not (vo_is_parentfp in tabstractnormalvarsym(p).varoptions) and
(tabstractnormalvarsym(p).varoptions*[vo_is_parentfp,vo_is_internal]=[]) and
not assigned(tabstractnormalvarsym(p).defaultconstsym);
end;

31
tests/webtbs/tw39857.pp Normal file
View File

@ -0,0 +1,31 @@
{ %OPT = -gt }
program tw39857;
{$mode objfpc}{$H+}
{$ModeSwitch anonymousfunctions}
{$ModeSwitch functionreferences}
type
TProc = reference to procedure;
procedure problem(aParam1: integer; aParam2: integer; aParam3: TProc);
begin
Writeln(aParam1, aParam2);
end;
procedure noproblem(aParam1: integer; aParam2: integer; aParam3: IUnknown);
begin
Writeln(aParam1, aParam2);
end;
procedure test;
begin
noproblem(1, 2, TInterfacedObject.Create); // ok
problem(3,4, nil); // ok
problem(5,6, procedure begin Writeln('x'); end); // aParam3 is trashed
end;
begin
test;
end.