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

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