Re: [fpc-pascal] Fpc Bug 3.0: Generics and Operator Overloading

2016-03-06 Thread Mazola Winstrol
2016-03-06 19:48 GMT-03:00 Mazola Winstrol :


> Done. Issued as #0029792. 
>
>
The link is wrong. =)

Issued here: #0029792 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Fpc Bug 3.0: Generics and Operator Overloading

2016-03-06 Thread Mazola Winstrol
2016-03-06 17:45 GMT-03:00 Sven Barth :

> Yes, that's a bug. Please report.
>
> Regards,
> Sven
>
>
Done. Issued as #0029792. 

Regards
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Fpc Bug 3.0: Generics and Operator Overloading

2016-03-06 Thread Sven Barth
Am 06.03.2016 19:42 schrieb "Mazola Winstrol" :
>
> Hello,
>
> Fpc version: 3.0 (the one included with Lazarus 1.6).
>
> Please confirm if it is a bug: it seems the compiler doesn't handle
operator overloading properly when using generic record with local
specializations.

Yes, that's a bug. Please report.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Fpc Bug 3.0: Generics and Operator Overloading

2016-03-06 Thread Mazola Winstrol
Hello,

Fpc version: 3.0 (the one included with Lazarus 1.6).

Please confirm if it is a bug: it seems the compiler doesn't handle
operator overloading properly when using generic record with local
specializations.


= Code =

unit Test;

{$mode delphi}

type
  TMyRecord = record
class operator Add(A,B: TMyRecord): TMyRecord;
  end;

implementation

class operator TMyRecord.Add(A,B: TMyRecord): TMyRecord;
begin
// add implementation
end;


procedure TestIfCompiles;
type
  TInteger = TMyRecord;
var
  N1, N2: TInteger;
begin
  N1 := N2 + N2;  /// DOES NOT COMPILE: Operator is not overloaded:
TMyRecord + TMyRecord
end;

 END =



To compile this code, move the declarion of the type TInteger to the global
scope, as follows:



= Code =

unit Test;

{$mode delphi}

type
  TMyRecord = record
class operator Add(A,B: TMyRecord): TMyRecord;
  end;

   TInteger = TMyRecord;


implementation

class operator TMyRecord.Add(A,B: TMyRecord): TMyRecord;
begin
// add implementation
end;


procedure TestIfCompiles;
var
  N1, N2: TInteger;
begin
  N1 := N2 + N2;
end;

 END =


Regards
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal