Operator overloading is not working properly with the types of byte, word, cardinal
Original Reporter info from Mantis: Kverde
-
Reporter name:
Original Reporter info from Mantis: Kverde
- Reporter name:
Description:
type
TMyRecord = record
a: Byte;
b: Word;
end;
operator := (A: Byte) : TMyRecord;
operator := (A: Word) : TMyRecord;
implementation
operator:=(A: Byte): TMyRecord;
begin
Result.A := A;
Result.B := 0;
end;
operator:=(A: Word): TMyRecord;
begin
Result.A := 0;
Result.B := A;
end;
...
MyRecord1 := 255;
MyRecord2 := 256;
Writeln('MyRecord1.a = ', MyRecord1.a); // 255
Writeln('MyRecord1.b = ', MyRecord1.b); // 0
Writeln('MyRecord2.a = ', MyRecord2.a); // 0
Writeln('MyRecord2.b = ', MyRecord2.b); // 0 // there should be 256
Mantis conversion info:
- Mantis ID: 24548
- Version: 2.6.2