Skip to content

Internal error when compiling an anonymous function that returns String

When compiling the following program, an error occurs "Internal error 2011010304"

program project5;

{$mode delphi}
{$modeswitch anonymousfunctions}
{$modeswitch functionreferences}

//uses
//  SysUtils;

type
  TFunc1 = reference to function (P1: Integer): String;

function GetTestFunc1(P2: Integer): TFunc1;
begin
  Result := function (P1: Integer): String begin
      Result := '3'; // <-- Error: Internal error 2011010304
      //Result := IntToStr(P1 + P2);
    end;
end;

begin
  if GetTestFunc1(1)(2) <> '3' then
    Halt(1);
end.

The error is regression.

Edited by Sergey Larin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information