[fpc-pascal] Operator overload bug

Ben Grasset operator97 at gmail.com
Mon Jul 23 02:22:25 CEST 2018


Also, one other thing: you should *really* be specifying the
right-hand-side array parameter as "const" there. If you don't, it will be
copied in its entirety instead of being passed by reference. Basically just
always pass everything as "const"  (or "constref" if it's specifically a
record) unless you literally can't.

On Sun, Jul 22, 2018 at 12:10 PM, Ryan Joseph <ryan at thealchemistguild.com>
wrote:

> I mentioned this as an aside a while ago but I don’t remember getting a
> response so I’d like to formally reintroduce the issue.
>
> Should I file a bug report for this or is it expected behavior? Personally
> I’d really like to get implicit array overloads working properly.
>
>
>
>
> program test;
>
> type
>         TMyClass = class
>         end;
>
> operator + (left: TMyClass; right: array of integer): TMyClass; overload;
> var
>         i: integer;
> begin
>         for i in right do
>                 writeln('add ', i);
>         result := left;
> end;
>
> var
>         c: TMyClass;
> begin
>         c += [1, 2, 3]; // ERROR: Operator is not overloaded: "TMyClass" +
> "Set Of Byte"
> end.
>
> Regards,
>         Ryan Joseph
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180722/f0466ede/attachment.html>


More information about the fpc-pascal mailing list