소스 검색

* fix #40031: with support for inline specializations it no longer makes sense to make the parameter symtable of a procedure variable type readonly as there *are* defs that are added to it
+ add adjusted test

Sven/Sarah Barth 2 년 전
부모
커밋
e1288897f3
2개의 변경된 파일16개의 추가작업 그리고 3개의 파일을 삭제
  1. 0 3
      compiler/ptype.pas
  2. 16 0
      tests/webtbs/tw40031.pp

+ 0 - 3
compiler/ptype.pas

@@ -1613,8 +1613,6 @@ implementation
             parse_generic:=(df_generic in pd.defoptions);
             if parse_generic and not assigned(current_genericdef) then
               current_genericdef:=old_current_genericdef;
-            { don't allow to add defs to the symtable - use it for type param search only }
-            tparasymtable(pd.parast).readonly:=true;
 
             if token=_LKLAMMER then
               parse_parameter_dec(pd);
@@ -1639,7 +1637,6 @@ implementation
                 pd.check_mark_as_nested;
               end;
             symtablestack.pop(pd.parast);
-            tparasymtable(pd.parast).readonly:=false;
             { possible proc directives }
             if parseprocvardir then
               begin

+ 16 - 0
tests/webtbs/tw40031.pp

@@ -0,0 +1,16 @@
+program tw40031;{$mode objfpc}{$modeswitch functionreferences}{$modeswitch anonymousfunctions}
+type Aoc0 = reference to procedure (aoc: array of const);
+type Aoc1 = reference to procedure (var aoc: array of const);
+type Aoc2 = reference to procedure (constref aoc: array of const);
+type Aoc3 = reference to procedure (const aoc: array of const);
+var
+  t: aoc0;
+  i: longint;
+begin
+  i := 0;
+  t := procedure(aArgs: array of const) begin i:=length(aArgs); end;
+  t([1, 'Hello']);
+  if i <> 2 then
+    halt(1);
+end.
+