Browse Source

* fix #40708: when creating the sub-arraydefs for comma separated arrays, ensure that the new sub array also has the generic related information set up correctly
+ added test

Sven/Sarah Barth 1 year ago
parent
commit
550397b982
2 changed files with 18 additions and 0 deletions
  1. 4 0
      compiler/ptype.pas
  2. 14 0
      tests/webtbs/tw40708.pp

+ 4 - 0
compiler/ptype.pas

@@ -1623,6 +1623,10 @@ implementation
                       symtablestack.pop(arrdef.symtable);
                       symtablestack.pop(arrdef.symtable);
                       arrdef:=tarraydef(arrdef.elementdef);
                       arrdef:=tarraydef(arrdef.elementdef);
                       symtablestack.push(arrdef.symtable);
                       symtablestack.push(arrdef.symtable);
+                      { correctly update the generic information of the new array def }
+                      insert_generic_parameter_types(arrdef,genericdef,genericlist,false);
+                      if old_parse_generic then
+                        include(arrdef.defoptions,df_generic);
                     end
                     end
                   else
                   else
                     begin
                     begin

+ 14 - 0
tests/webtbs/tw40708.pp

@@ -0,0 +1,14 @@
+{ %NORUN }
+
+program tw40708;
+
+{$mode objfpc}
+
+type generic TMatrix4<T> = array[0..3] of array [0..3] of T; // works
+type generic TAnotherMatrix4<T> = array[0..3,0..3] of T; // "Identifier not found T"
+
+type TMatrix4LongInt = specialize TMatrix4<LongInt>;
+type TAnotherMatrix4LongInt = specialize TAnotherMatrix4<LongInt>;
+begin
+end.
+