Getting access violation errors if I use an inline declared record variable to build a dynamic record array. Does not happen all the time but switching back to a normal declaration for the record variable I haven't seen the error. I wonder if this is a limitation of inline variable declaration or either way I am doing something wrong.
procedure TForm1.FormCreate(Sender: TObject);
Type
RFruit = record
FruitName : string;
FruitBitMask : Int64;
end;
Var
//AFruitRec : RFruit;
Fruits : array of string;
FruitList : array of RFruit;
begin
Fruits := ['Orange','Apple','Pear','Peach','Grape'];
Var AFruitRec : RFruit;
for var i :integer := 0 to length(Fruits) - 1 do
begin
AFruitRec.FruitName := Fruits[i];
AFruitRec.FruitBitMask := Int64(1) SHL i;
FruitList := FruitList + [AFruitRec];
end;
end;