2
0
Эх сурвалжийг харах

* 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 жил өмнө
parent
commit
e1288897f3

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