Skip to content

wrong property value with nested object #7

@User4martin

Description

@User4martin

In the below the field for the property is in a nested record/object.

run to the "write" line.

pdr) p f
F = TFoo(@$00007F031C8E0060) { x: TRec { a: 11, b: TT { a1: ..., b1: ... } }, n: 0, y: TRec { a: 21, b: TT { a1: ..., b1: ... } }, t: 21 }

However, the correct value is "22".

program project1; {$Mode objfpc}
type
  TT = record
    a1,b1:word;
  end;
  TRec = object
    a: byte;
    b: TT;
  end;
  TFoo = class
  protected
    x: TRec;
    n: integer;
    y: TRec;
  public
    property t: word read y.b.a1;
  end;

var f : TFoo;

begin
  f:=TFoo.Create;
  f.x.a:=11;
  f.x.b.a1:=12;
  f.y.a:=21;
  f.y.b.a1:=22;
  write(f.t);
end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions