The following snippet, in XE6
procedure TForm1.Test(CDS : TClientDataSet);
var
AGuid : TGuid;
lResult : Longint;
begin
lResult := SysUtils.CreateGUID(AGuid);
CDS.InsertRecord([AGuid, '', False]);
end;
produces the error message
[dcc32 Error] Unit1.pas(73): E2150 Bad argument type in variable type array constructor
Fwiw, in discovering this, I was trying to retrace my steps to a previous version of this routine where the compiler was generating the error
E2197 Constant object cannot be passed as var parameter
on the line
lResult := SysUtils.CreateGUID(AGuid);
despite the fact that what was provoking it turned out to be an error in the subsequent code.
This is the declaration of the
InsertRecord
method:The parameter is a variant open array. Variant open array parameters are implemented internally by being passed as
TVarRec
instances. AndTVarRec
cannot contain records. SinceTGUID
is a record, it cannot be passed in a variant open array parameter.