Copy/Cloning of inlined nested records broken for JS

Issue #106 new
Dany Marmur created an issue

With this piece of code:

unit Test;

interface

type
  RMasterRecord = record
    Info: string = 'Test';
    RSubRecord = record
      Info: Integer = 10;
      Flag: Boolean = false;
    end;
  end;

implementation

var gRec: RMasterRecord;

function Copy(const aRec: RMasterRecord): RMasterRecord;
begin
  Result := aRec;
end;

initialization

Copy(gRec);

end.

i get the following JS output:

/// RMasterRecord = record
function Copy$RMasterRecord(s,d) {
   d.Info$1=s.Info$1;
   Copy$a$1(s.RSubRecord,d.RSubRecord);
   return d;
}
function Clone$RMasterRecord($) {
   return {
      Info$1:$.Info$1,
      RSubRecord:Clone$a$1($.RSubRecord)
   }
}
function Copy$1(aRec) {
   return Clone$RMasterRecord(aRec);
};
var gRec = {Info$1:"Test",RSubRecord:{Info:10,Flag:false}};
Copy$1(gRec);

As you can see Copy$a$1 and Clone$a$1 did not make it into the output.

This worked fine in my deployed project at the commit of 16 march.

Regards,

/Dany

Comments (5)

  1. Dany Marmur reporter

    A workaround that does not imply changing all references is to declare the nested records separately.

    type
      RSubRecord = record
        Member1.Integer = 0;
      end;
    
      RMasterRecord = record
        Member1: string = 'Init';
        Member2: RSubRecord;
      end;
    
  2. Log in to comment