Sets from units compiled in different mode are not (type cast) compatible: Error: Illegal type conversion: TypeX to TypeY
Original Reporter info from Mantis: Jesus @jramx
-
Reporter name: Jesus Reyes
Original Reporter info from Mantis: Jesus @jramx
- Reporter name: Jesus Reyes
Description:
I think this is a regression introduced in r23898, bug?, feature?
if given:
type
TSetA = set of (saA,saB);
TSetB = set of (sbA,sbB);
var
a: TSetA;
b: TSetB;
begin
// one could do
b := TSetB(a); // or
a := TSetA(b);
// and it works
end;
now, if TSetA is declared in unita which is compiled in {mode Delphi} and TSetB is declared in unit which is compiled in {
mode ObjFPC} the before mentioned assignments won't work.
Steps to reproduce:
fpc main.pas
compiling main.pas
compiling unita.pas
compiling unitb.pas
main.pas(8,10) Error: Illegal type conversion: "TSetA" to "TSetB"
main.pas(9,10) Error: Illegal type conversion: "TSetB" to "TSetA"
main.pas(10,4) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
--- content of files below ----
unit unita;
{$mode Delphi}
interface
type
TSetA=set of (saA,saB);
implementation
end.
unit unitb;
{$mode ObjFPC}
interface
type
TSetB=set of (sbA,sbB);
implementation
end.
{$mode ObjFPC}
program test;
uses unita, unitb;
var
a: TSetA;
b: TsetB;
begin
b := TSetB(a);
a := TSetA(b);
end;
Additional information:
Mantis conversion info:
- Mantis ID: 24123
- Build: r23958
- Version: 2.7.1
- Target version: 2.7.1