Przeglądaj źródła

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

Sven/Sarah Barth 2 lat temu
rodzic
commit
5135b586cb
2 zmienionych plików z 32 dodań i 1 usunięć
  1. 1 1
      compiler/ngenutil.pas
  2. 31 0
      tests/webtbs/tw39857.pp

+ 1 - 1
compiler/ngenutil.pas

@@ -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 - 0
tests/webtbs/tw39857.pp

@@ -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.