<div dir="ltr"><div><div>Hello,<br><br>Fpc version: 3.0 (the one included with Lazarus 1.6).<br><br></div>Please confirm if it is a bug: it seems the compiler doesn't handle operator overloading properly when using generic record with local specializations. <br><br><br></div><div>===== Code =====<br><br></div><div>unit Test;<br><br></div><div>{$mode delphi}<br></div><div><br></div><div>type<br></div><div>  TMyRecord<T> = record<br></div><div>    class operator Add(A,B: TMyRecord<T>): TMyRecord<T>;</div><div>  end;<br><br></div><div>implementation<br><br></div><div>class operator TMyRecord<T>.Add(A,B: TMyRecord<T>): TMyRecord<T>;<br></div><div>begin<br></div><div>// add implementation<br></div><div>end;<br><br><br></div><div>procedure TestIfCompiles;<br></div><div>type<br></div><div>  TInteger = TMyRecord<Integer>;<br></div><div>var<br></div><div>  N1, N2: TInteger;<br></div><div>begin<br></div><div>  N1 := N2 + N2;  /// DOES NOT COMPILE: Operator is not overloaded: TMyRecord + TMyRecord<br></div><div>end;<br></div><div><br></div><div>==== END =====<br><br><br></div><div><br>To compile this code, move the declarion of the type TInteger to the global scope, as follows:<br><br><br><br><div>===== Code =====<br><br></div><div>unit Test;<br><br></div><div>{$mode delphi}<br></div><div><br></div><div>type<br></div><div>  TMyRecord<T> = record<br></div><div>    class operator Add(A,B: TMyRecord<T>): TMyRecord<T>;</div><div>  end;<br>  <br>   TInteger = TMyRecord<Integer>;<br><br><br></div><div>implementation<br><br></div><div>class operator TMyRecord<T>.Add(A,B: TMyRecord<T>): TMyRecord<T>;<br></div><div>begin<br></div><div>// add implementation<br></div><div>end;<br><br><br></div><div>procedure TestIfCompiles;<br></div><div>var<br></div><div>  N1, N2: TInteger;<br></div><div>begin<br></div><div>  N1 := N2 + N2;  <br></div><div>end;<br></div><div><br></div>==== END =====<br></div><div><br></div><div><br>Regards<br></div><div><br></div></div>