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.