[fpc-devel] Interchangeability between array of Const and array of TVarRec. Bug?

Luiz Americo Pereira Camara luizmed at oi.com.br
Thu Nov 3 17:26:46 CET 2011


Hi,

I can pass an array of TVarRec to a procedure that expects an array of 
const like below:

procedure Test(Args: array of const);
begin
   //do something with args
end;

var
   a: array of TVarRec;
   s: String;

begin
   SetLength(a, 2);
   a[0].VType := vtInteger;
   a[0].VInteger := 3;
   a[1].VType := vtAnsiString;
   s := 'xx';
   a[1].VAnsiString := PAnsiString(s);
   Test(a);
end.


But when i try to do the inverse (pass an array of const to an array of 
TVarRec) i get the following error:

Error: Incompatible type for arg no. 1: Got "Array Of Const\Constant 
Open Array of ShortInt", expected "Open Array Of TVarRec"

procedure Test(Args: array of TVarRec);
begin
   //do something with args
end;

begin
   Test([3, 'xx']);
end.


Is that a bug or a limitation of the language?

Using FPC 2.4.4 i386-win32

Luiz





More information about the fpc-devel mailing list