Implicit operator overloading and record type output

Issue #130 resolved
Former user created an issue

Hello. I have a problem with overloading an implication operator that returns a record type. It looks like an empty record is returned.

Script sample:

type
  TFoo = record
    X, Y: Integer;
  end;

function FooImplInt(I: Integer): TFoo;
begin
  Result.X := I;
  Result.Y := I;
end;

function FooAddInt(F: TFoo; I: Integer): TFoo;
begin
  Result.X := F.X + I;
  Result.Y := F.Y + I;
end;

operator implicit (Integer): TFoo uses FooImplInt;
operator + (TFoo,Integer): TFoo uses FooAddInt;

var
  F1, F2, F3: TFoo;

begin
  F1 := 10;
  F2 := FooImplInt(10);
  F3 := F2 + 10;
  //writeln('F1 X=' + inttostr(F1.X) + ' Y=' + inttostr(F1.Y));
  // output: F1 X=0 Y=0
  //writeln('F2 X=' + inttostr(F2.X) + ' Y=' + inttostr(F2.Y));
  // output: F2 X=10 Y=10
  //writeln('F3 X=' + inttostr(F3.X) + ' Y=' + inttostr(F3.Y));
  // output: F3 X=20 Y=20
end.

Comments (1)

  1. Log in to comment