Implicit operator overloading and record type input

Issue #131 resolved
michalgw created an issue

Thank you for resolving #130. Now I have a similar problem with overloading the assignment operator, but this time the left side is Integer and the right side is a record. I get the exception EVariantBadVarTypeError with the message "Invalid variant type". P.S. I'm using dwcript with freepascal.

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

function OperImpFooInt(AFoo: TFoo): Integer;
begin
  Result := AFoo.X + AFoo.Y;
end;

operator implicit (TFoo): Integer uses OperImpFooInt;

var F: TFoo;
var I: Integer;

begin
  F.X := 10;
  F.Y := 11;
  I := F;
end.

Comments (2)

  1. Eric Grange repo owner

    Exception was not triggered in Delphi by your snippet, but required a small variation.

    Hopefully I fixed your bug, otherwise, well, I have fixed another bug :)

  2. Log in to comment