瀏覽代碼

* when assigning an anonymous function to a method pointer move the function to the normal function level to avoid potential problems when accessing other variables

Sven/Sarah Barth 2 年之前
父節點
當前提交
d410deb7ae
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      compiler/ncnv.pas

+ 5 - 0
compiler/ncnv.pas

@@ -2501,6 +2501,11 @@ implementation
                         ) then
                         ) then
                       internalerror(2021060801);
                       internalerror(2021060801);
 
 
+                    { we know this only captures Self, so we can move the
+                      anonymous function to normal function level }
+                    pd.parast.symtablelevel:=normal_function_level;
+                    tprocdef(pd).localst.symtablelevel:=normal_function_level;
+
                     selfsym:=nil;
                     selfsym:=nil;
                     fpsym:=nil;
                     fpsym:=nil;
                     { find the framepointer parameter and an eventual self }
                     { find the framepointer parameter and an eventual self }