Browse Source

* set names of record defs (and objects) correctly after copying them, resolves #41565

florian 1 week ago
parent
commit
6b1f77c267
2 changed files with 12 additions and 0 deletions
  1. 4 0
      compiler/pdecl.pas
  2. 8 0
      compiler/symdef.pas

+ 4 - 0
compiler/pdecl.pas

@@ -961,6 +961,10 @@ implementation
                         end;
 
                       include(hdef.defoptions,df_unique);
+
+                      { update object's real name for better error messages }
+                      if hdef is tabstractrecorddef then
+                        tabstractrecorddef(hdef).setobjrealname(newtype.RealName);
                     end;
                   if not assigned(hdef.typesym) then
                     begin

+ 8 - 0
compiler/symdef.pas

@@ -372,6 +372,8 @@ interface
           function is_visible_for_rtti(option: trtti_option; vis: tvisibility): boolean; inline;
           function rtti_visibilities_for_option(option: trtti_option): tvisibilities; inline;
           function has_extended_rtti: boolean; inline;
+          { update the name of the object, typically needed after getcopy }
+          procedure setobjrealname(const n: string);
        end;
 
        pvariantrecdesc = ^tvariantrecdesc;
@@ -5350,6 +5352,12 @@ implementation
       end;
 {$endif DEBUG_NODE_XML}
 
+    procedure tabstractrecorddef.setobjrealname(const n:string);
+      begin
+        Freemem(objrealname);
+        objrealname:=stringdup(n);
+      end;
+
 {***************************************************************************
                                   trecorddef
 ***************************************************************************}