Search code examples
delphi-7freepascal

FreePascal syntax error "invalid qualifier", but it compiles in Delphi 7


The code below compiles in Delphi 7, but gives an error in FPC. Is there any mode switch that makes it compile?

procedure Test;
type
  TArray = array of Integer;
  TArrayFunc = function: TArray;
var
 a: TArray;
 f: TArrayFunc;
 i: integer;
begin
 i := f[0]; //* FPC: "Error: Illegal qualifier"
 i := f()[0]; //* Compiles in D7 and FPC
end;

Solution

  • It is a bug in FPC 3.2.2. I just fixed it in FPC 3.3.1: https://gitlab.com/freepascal.org/fpc/source/-/commit/ec28b7586c4b74823555f196772743fe9bfa3dde