Hello, Fpc version: 3.0 (the one provided by Lazarus).
Please confirm if this is a bug regarding operator overloading and type specialization. It is a quite difficult to explain, but i will try. Consider this unit === CODE === unit MyRecordDefinitionA; {$mode delphi} interface type TMyRecord<T> = record public FValue: T; class operator Add(A,B: TMyRecord<T>): TMyRecord<T>; end; implementation class operator TMyRecord<T>.Add(A,B: TMyRecord<T>): TMyRecord<T>; begin Result.FValue := A.FValue + B.FValue; end; end. === END === The unit above defines a generic type named TMyRecord with the arithmetic operator overloaded Add. This type is supposed to be specialized with a type parameter that supports the add operation (e.g Integer types). === CODE === unit MyRecordDefinitionB; {$mode delphi} interface type TMyRecord<T> = record public FValue: T; class operator LogicalAnd(A: TMyRecord<T>; B: Boolean): TMyRecord<T>; end; implementation class operator TMyRecord<T>.LogicalAnd(A: TMyRecord<T>; B: Boolean): TMyRecord<T>; begin Result.FValue := A.FValue and B; end; end. === END === The unit above defines a generic type named TMyRecord too, but with the logical operator overloading And. This type is supposed to be specialized with a type parameter that supports the logical and operation (e.g Boolean types). === CODE === unit MyRecordSpecialization; {$mode delphi} interface uses MyRecordDefinitionA, MyRecordDefinitionB; type TMyIntegerRecord = MyRecordDefinitionA.TMyRecord<Integer>; TMyBooleanRecord = MyRecordDefinitionB.TMyRecord<Boolean>; implementation end. === END === The unit above defines two specialized types based on the generic type TMyRecord defined in the units MyRecordDefinitionA and MyRecordDefinitionB. When i try to compile MyRecordSpecialization, i get this error: "Operator is not overloaded: LongInt and Boolean". It seems the compiler treats the type MyRecordDefinitionA.TMyRecord and MyRecordDefinitionB.TMyRecord as being the same type. So, the compiler try to apply the logical operator and of MyRecordDefinitionB.TMyRecord in the integer specialization of the type MyRecordDefinitionA.TMyRecord. Regards
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal