[Lazarus] "global" operator overloading

Sven Barth pascaldragon at googlemail.com
Tue Feb 26 15:35:12 CET 2013


On 26.02.2013 15:30, Xiangrong Fang wrote:
> Hi Sven,
>
> My code below:
>
> ===============================================
> program project1;
> {$mode objfpc}{$H+}
> {$MODESWITCH advancedrecords}
>
> uses Classes;
> type
>    TMyStringList = record
>      StringList: TStringList;
>      class operator <(s1, s2: TMyStringList): Boolean;
>    end;
>
> class operator TMyStringList.<(s1, s2: TMyStringList): Boolean;
> begin
>    Result := s1.StringList.Count < s2.StringList.Count;
> end;
>
> begin
> end.
> ===============================================
>
> generated these errors:
>
> project1.lpr(9,20) Error: It is not possible to overload this operator.
> Related overloadable operators (if any) are:
> project1.lpr(9,21) Error: It is not possible to overload this operator.
> Related overloadable operators (if any) are:
> project1.lpr(9,53) Error: Impossible operator overload
> project1.lpr(12,31) Error: method identifier expected
> project1.lpr(1,1) Fatal: Compilation aborted
>
> I am using Lazarus 1.0.6/FPC2.6.0-6  on Linux Mint 14/x86_64.

Hmm... 2.6.0 seems to indeed have problems there. I did not test 2.6.2 
(I don't have it installed yet), but 2.7.1 works without problems.

Regards,
Sven





More information about the Lazarus mailing list