Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-11

Interchangeability between array of Const and array of TVarRec. Bug?

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luiz Americo Pereira Camara

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

Reply by email