Hello, Fpc version: 3.0 (the same included with lazarus 1.6).
Please confirm if it is a bug: If i declare a generic record with overloaded add operation, i need to specialize the type in the same unit for the compiler recognize the overloading. === Code === unit MyRecordDefinition; {$mode delphi} interface type TMyRecord<T> = record class operator Add(A,B: TMyRecord<T>): TMyRecord<T>; end; implementation class operator TMyRecord<T>.Add(A,B: TMyRecord<T>): TMyRecord<T>; begin //// end; end. ...................... Unit MyRecordSpecialization; {$mode delphi} interface uses MyRecordDefinition; type TInteger = TMyRecord<Integer>; implementation procedure TestIfCompiles; var N1, N2: NullableInteger; begin N1 := N2 + N2; // DOESN'T COMPILE: Operator is not overloaded: TMyRecord + TMyRecord end; end. ==== END ==== To get this code compiled, i need to move the specialized type TInteger to the same unit where the generic type TMyRecord is declared. ==== code === unit MyRecordDefinition; {$mode delphi} interface type TMyRecord<T> = record class operator Add(A,B: TMyRecord<T>): TMyRecord<T>; end; TInteger = TMyRecord<Integer>; implementation class operator TMyRecord<T>.Add(A,B: TMyRecord<T>): TMyRecord<T>; begin //// end; end. ...................... Unit MyRecordSpecialization; {$mode delphi} interface uses MyRecordDefinition; implementation procedure TestIfCompiles; var N1, N2: NullableInteger; begin N1 := N2 + N2; // DOESN'T COMPILE: Operator is not overloaded: TMyRecord + TMyRecord end; end. === END ==== Best regards
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal