Delphi Error – E2150 Bad argument type in variable type array constructor

Delphi Compiler Error

E2150 Bad argument type in variable type array constructor

Reason for the Error & Solution

You are attempting to construct an array using a type which is not allowed in variable arrays.

program Produce;

  type
    Fruit = (apple, orange, pear);
    Data = record
      x : Integer;
      ch : Char;
    end;

  var
    f : Fruit;
    d : Data;

  procedure Examiner(v : array of TVarRec);
  begin
  end;

begin
  Examiner([d]);
  Examiner([f]);
end.

Both calls to Examiner will fail because enumerations and records are not supported in array constructors.

program Solve;

  var
    i : Integer;
    r : Real;
    v : Variant;

  procedure Examiner(v : array of TVarRec);
  begin
  end;

begin
  i := 0; r := 0; v := 0;
  Examiner([i, r, v]);
end.

Many data types, like those in the example above, are allowed in array constructors.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...