Explorar o código

* fix #39795: when extracting make_prettystring it was forgotten to also append the const part of the name to the specialize name

Sven/Sarah Barth %!s(int64=3) %!d(string=hai) anos
pai
achega
b2a5334a75
Modificáronse 2 ficheiros con 20 adicións e 0 borrados
  1. 2 0
      compiler/pgenutil.pas
  2. 18 0
      tests/webtbs/tw39795.pp

+ 2 - 0
compiler/pgenutil.pas

@@ -101,6 +101,8 @@ uses
         if not assigned(module) then
           internalerror(2016112802);
         namepart:='_$'+hexstr(module.moduleid,8)+'$$'+paramtype.unique_id_str;
+        if constprettyname<>'' then
+          namepart:=namepart+'$$'+constprettyname;
         { we use the full name of the type to uniquely identify it }
         if (symtablestack.top.symtabletype=parasymtable) and
             (symtablestack.top.defowner.typ=procdef) and

+ 18 - 0
tests/webtbs/tw39795.pp

@@ -0,0 +1,18 @@
+program tw39795;
+{$mode objfpc}{$H+}
+
+type
+  generic GTestType<T,const S:byte>=class
+    type
+      TXX=array [0..S] of T;
+    var
+      XX:TXX;
+  end;
+  T2=specialize GTestType<byte,0>;
+  T3=specialize GTestType<byte,99>;
+begin
+  if sizeof(T2.TXX) <> 1 then
+    Halt(1);
+  if sizeof(T3.TXX) <> 100 then
+    Halt(2);
+end.