6

When compiled under Delphi 7 or Delphi XE, the code below complains

[DCC Error] Project1.dpr(25): E2010 Incompatible types: 'array of Char' and 'TAChar'

According to Rudy's article, it should be allowed to pass typed array to open array ?

Furthermore, why does it not complain for 'array of Boolean' and 'TABoolean' ?

Many thanks for help !

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  TAChar = array of Char;
  TABoolean = array of Boolean;

procedure Test1(const CharArr: array of Char);
begin
end;

procedure Test2(const BoolArr: array of Boolean);
begin
end;

var
  Arr1: TAChar;
  Arr2: TABoolean;
begin
  try
    Test1(Arr1);  //  <------- Does not compile in Delphi 7 & XE
    Test2(Arr2);
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
asd-tm
  • 3,381
  • 2
  • 24
  • 41
SOUser
  • 3,802
  • 5
  • 33
  • 63

1 Answers1

6

The code in the question is valid. Any compiler that refuses to compile it is defective. Probably there is little point submitting a bug report because modern versions will compile this code.

If you cannot move to a compiler that is not defective then you will have to work around the defect. Sertac's answer to a similar question demonstrates one such work around: https://stackoverflow.com/a/3781425/505088

Community
  • 1
  • 1
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490