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

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 X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...