Delphi Error – E2192 Constants cannot be used as open array arguments

Delphi Compiler Error

E2192 Constants cannot be used as open array arguments

Reason for the Error & Solution

Open array arguments must be supplied with an actual array variable, a constructed array or a single variable of the argument’s element type.

program Produce;

  procedure TakesArray(s : array of String);
  begin
  end;


begin TakesArray('Hello Error');
end.

The error is caused in this example because a string literal is being supplied when an array is expected. It is not possible to implicitly construct an array from a constant.

program Solve;

  procedure TakesArray(s : array of String);
  begin
  end;


begin TakesArray(['Hello Error']);
end.

The solution avoids the error because the array is explicitly constructed.

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...